How to change the port in ansible playbook

12/13/2019

My inventory file looks like this;

minikube

fatal: [minikube]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host minikube port 22: Operation timed out", "unreachable": true}

PLAY RECAP ************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
minikube                   : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0

But the playbook runs in port 22. I need to change it to 80. I followed the question, Ansible change ssh port in playbook I added a task to change the port. But still returns the same error.

How to fix this issue?

--
ansible
kubernetes
macos
minikube
ssh

1 Answer

12/13/2019

You should include the port in your inventory:

minikube ansible_port=80

This is discussed in Ansible's "How to build your inventory" documentation (which includes examples).

-- larsks
Source: StackOverflow