我有这个剧本 执行一些基本任务 在开关和防火墙上。
父母 :
- hosts: localhost
become: no
gather_facts: no
vars_prompt:
- name: ansible_user
prompt: "Enter Username"
private: no
- name: ansible_password
prompt: "Enter Password"
private: yes
- name: Execute Script on Switch
import_playbook: test_dummy_switch.yml
- name: Execute Script on Firewall
import_playbook: test_dummy_fw.yml
Child 1 / 开关: 测试_ dommy_ coreit.yml
- hosts: Switch
become: no
gather_facts: no
vars_prompt:
- name: ansible_user
prompt: "Enter Username"
private: no
- name: ansible_password
prompt: "Enter Password"
private: yes
tasks:
- name: Interface Config
ios_config:
lines:
- description Testing Switch
parents: "interface Gi0/0"
register: print_output
- debug: var=print_output
儿童 2 / 防火墙: 测试_ dummy_ fw.yml
- hosts: Firewall
become: no
gather_facts: no
vars_prompt:
- name: ansible_user
prompt: "Enter Username"
private: no
- name: ansible_password
prompt: "Enter Password"
private: yes
tasks:
- name: Interface Config
ios_config:
lines:
- description Testing Firewall
parents: "interface Ethernet1"
register: print_output
- debug: var=print_output
我想创建一个脚本, 以在父游戏本中设置变量时跳过提示 。 我也在游戏本中尝试过这一点, 但是 Assible 仍然提示着儿童游戏本中的变量 。
父母 :
- hosts: localhost
become: no
gather_facts: no
vars_prompt:
- name: ansible_user
prompt: "Enter Username"
private: no
- name: ansible_password
prompt: "Enter Password"
private: yes
tasks:
- set_fact:
ansible_user: "{{ ansible_user }}"
ansible_password: "{{ ansible_password }}"
- name: Execute Script on Switch
import_playbook: test_dummy_switch.yml
vars:
ansible_user: "{{ ansible_user|d( default ) }}"
ansible_password: "{{ ansible_password|d( default ) }}"
- name: Execute Script on Firewall
import_playbook: test_dummy_fw.yml
vars:
ansible_user: "{{ ansible_user|d( default ) }}"
ansible_password: "{{ ansible_password|d( default ) }}"
是否有办法可以确保不使用额外的变量 < / 强'来确认变量已经存在并跳过快速的 < 强 >? 因为仅需要此脚本的要求就可一次提示用户名和密码 。