Hi all,
I moved host variables from inventory to group_vars/all
:
In one example I have seen on a book seems that, once moved the variable from playbook to group_vars
, it is possible to remove vars:
section from playbook (like the playbook automagically discover the group_vars/all
. If I do that is not going to works. Still I need for vars: into playbook. Please see below. My question is: is it correct that I can remove vars:
from playbook or not? In case is possible, what am I doing wrong?
From this:
vars:
cisco_asa:
host: “{{ ansible_host }}”
username: “{{ username }}”
password: “{{ password }}”
authorize: “yes”
auth_pass: “{{ auth_pass }}”
transport: cli
timeout: 60
snmp_host: [10.42.9.61, 10.42.9.62]
tasks:
- name: add new TSDP IPs
asa_config:
lines: - snmp-server host transit {{ item }} community 0 SaNu9eSu
provider: “{{ cisco_asa }}”
with_items: “{{ snmp_host }}”
register: result - debug:
var: result
to this:
vars:
cisco_asa:
host: “{{ ansible_host }}”
username: “{{ username }}”
password: “{{ password }}”
authorize: “yes”
auth_pass: “{{ auth_pass }}”
transport: cli
timeout: 60
snmp_host: [10.42.9.61, 10.42.9.62]
tasks:
- name: add new TSDP IPs
asa_config:
lines: - snmp-server host transit {{ item }} community 0 SaNu9eSu
provider: “{{ cisco_asa }}”
with_items: “{{ snmp_host }}”
register: result
- debug:
var: result
federico@federico:~/git/ansible_cisco $ ansible-playbook playbooks/update_snmp_asa.yml --check
PLAY [cisco_test] ************************************************************************************************************************************
TASK [add new TSDP IPs] ******************************************************************************************************************************
failed: [IE23PVPNFW01] (item=10.42.9.61) => {“changed”: false, “failed”: true, “item”: “10.42.9.61”, “msg”: “unable to open shell. Please see: https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell”}
failed: [IE23PVPNFW01] (item=10.42.9.62) => {“changed”: false, “failed”: true, “item”: “10.42.9.62”, “msg”: “unable to open shell. Please see: https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell”}
PLAY RECAP *******************************************************************************************************************************************
IE23PVPNFW01 : ok=0 changed=0 unreachable=0 failed=1