Question:
Here is the inventory file
1 2 3 4 5 6 7 8 |
--- [de-servers] 192.26.32.32 [uk-servers] 172.21.1.23 172.32.2.11 |
and my playbook is look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
- name: Install de-servers configurations hosts: de-servers roles: - de-server-setup - name: Install uk-servers configurations hosts: uk-servers roles: - uk-server-setup - name: Do some other job on de-servers (cannot be done until uk-servers is installed) hosts: de-servers roles: - de-servers-rest-of-jobs |
In role de-servers-setup role the ssh port is changed from 22 to 8888, so when the last task is called it fails because it cannot connect to host through 22 port. How to overcome this ssh port change?
Answer:
In the role de-server-setup
add a task to change the ansible_port
host variable.
1 2 3 4 |
- name: Change ssh port to 8888 set_fact: ansible_port: 8888 |