name: Include vars for vcenter
include_vars:
file: /etc/ansible/roles/createvm/vars/main.yml
name: vcenter
vars:
ansible_become_password: “{{ domain_password }}”
name: Include vars of server.yaml file
include_vars:
file: /etc/ansible/servers/{{ hostname }}.yaml
name: server
name: Wait For Connection to Continue
wait_for_connection:
connect_timeout: 30
name: Reboot to check for second round of updates
ansible.windows.win_reboot:
msg: “Reboot to check for second round of updates”
import_role:
name: windowsupdates
This playbook works fine if I run the command to specify 1 hostname:
TASK [Include vars of server.yaml file] ****************************************************************************************************************************************************************
task path: /etc/ansible/roles/secwinupdates/tasks/main.yml:12
fatal: [server1]: FAILED! => {
“ansible_facts”: {
“server”: {}
},
“ansible_included_var_files”: ,
“changed”: false,
“message”: “Could not find or access ‘/etc/ansible/servers/win_us_bgrsuistg.yaml’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”
}
fatal: [server2]: FAILED! => {
“ansible_facts”: {
“server”: {}
},
“ansible_included_var_files”: ,
“changed”: false,
“message”: “Could not find or access ‘/etc/ansible/servers/win_us_bgrsuistg.yaml’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”
}
fatal: [server3]: FAILED! => {
“ansible_facts”: {
“server”: {}
},
“ansible_included_var_files”: ,
“changed”: false,
“message”: “Could not find or access ‘/etc/ansible/servers/win_us_bgrsuistg.yaml’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”
}
I tried to create a seperate yaml file for the servers, called win_us_bgrsuistg , which includes the server1, server2, server 3 names in it, I then got the below error:
fatal: [server1]: FAILED! => {
“ansible_facts”: {
“server”: {}
},
“ansible_included_var_files”: ,
“changed”: false,
“message”: “/etc/ansible/servers/win_us_bgrsuistg.yaml must be stored as a dictionary/hash”