我有select.yml的IP和machine_id.yml的提示符,这应该包括从select.yml,并应该从select.yml主机。我尝试了许多配置,但都没有成功。
如何重用machine_id.yml并向其中注入主机?
select.yml
- hosts: localhost
gather_facts: no
vars_prompt:
- name: target_host
prompt: "[M] please enter the target host IP"
private: no
tasks:
- add_host:
name: "{{ target_host }}"
groups: dynamic_hosts
- import_playbook: machine_id.ymlmachine_id.yml
- hosts: localhost
gather_facts: no
vars_prompt:
- name: target_host
prompt: please enter the target host IP
private: no
tasks:
- add_host:
name: "{{ target_host }}"
groups: dynamic_hosts
- hosts: "{{ dynamic_hosts }}"
vars:
ansible_python_interpreter: /usr/bin/python3
become: yes
tasks:
- name: Reset machine-id
shell: rm /etc/machine-id && rm /var/lib/dbus/machine-id && dbus-uuidgen --ensure=/etc/machine-id && dbus-uuidgen --ensure
args:
warn: no发布于 2020-08-30 00:01:55
你走在正确的道路上。- import_playbook: machine_id.yml必须在- hosts:级别
下面是一个适用于我的示例:
select.yaml:
- hosts: localhost
gather_facts: no
vars_prompt:
- name: target_host
prompt: "[M] please enter the target host IP"
private: no
tasks:
- add_host:
name: "{{ target_host }}"
groups: dynamic_hosts
- debug: var=groups
- import_playbook: machine_id.yamlmachine_id.yaml:
- hosts: dynamic_hosts
gather_facts: no
tasks:
- ping:你能试一试吗?如果它不工作,请让我们知道你的错误。
https://stackoverflow.com/questions/63648231
复制相似问题