I am creating an ansible playbook for upgrade of my network devices. There are few command which I am running on Mgmt appliance and then there is a role to run command on the device it self. This process repeats three times with diff tasks.
As of now I am defining mgmt login variables and device login variables in each task which is creating duplicay. is there any way to define standard variables like global variables and use them in diff tasks?
I can’t define variables in inventory or can’t var files, I have to do in playbook.
Connection: httapi
Vars:
Ansible_user: “test”
Ansible_password: “test2”
Ansible_httpapi_use_ssl: True
Ansible_network_os: test3
Task:
- name : “Change Gateway Version”
Include_role:
name:etc/change_name
-host: test5
connection: local
gather_facts: false
Vars:
ansible_user: “gateway1″
ansible_password:”gateway2”
ansible_network_os: “test4”
Tasks:
-name: Run_isntallation
Include_role:
name: etc/installation_gateway
When:
These tasks repeat 3-4 times.
This is just example of what I am trying to write .
I tried several methods like defining host vars in set facts and calling those vars however it didn’t work
Query master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.