You’ve created user on the jump host
server. I’ve replied to you on the other topic, please check.
Hi Team,
I am at task1, creating ansible playbook to create an empty file on appServer2, it says host not reachable.
TASK [File creation] **********************************************************************************************************
fatal: [stapp02.stratos.xfusioncorp.com]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: Warning: Permanently added ‘172.16.238.11’ (ED25519) to the list of known hosts.\r\[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).”, “unreachable”: true}
PLAY RECAP ********************************************************************************************************************
stapp02.stratos.xfusioncorp.com : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
Can you help with this to proceed further.
What’s in your playbook and in your inventory? I saw something similar recently, so I’m testing a theory.
thor@jumphost ~/ansible$ cat inventory
stapp02.stratos.xfusioncorp.com ansible_host= 172.16.238.11 ansible_user=jim ansible_ssh_common_args=‘-o StrictHostKeyChecking=no’
thor@jumphost ~/ansible$ cat playbook.yml
-
name: Create an empty file on AppServer2
hosts: stapp02.stratos.xfusioncorp.com
gather_facts: falsetasks:
- name: File creation
ansible.builtin.file:
path: /tmp/file.txt
state: touch
- name: File creation
I don’t think that inventory set-up will work; I’ve created this file, which lints as correct, but I wouldn’t swear by it. But it doesn’t work either. I’m thinking I need a setting in ansible.cfg that isn’t there by default, or that the networking just isn’t copacetic in that lab. But here’s my inventory file:
stapp01 ansible_connection=ssh ansible_user=tony ansible_host=stapp01.stratos.xfusioncorp.com ansible_password=Ir0nM@n
stapp02 ansible_connection=ssh ansible_user=steve ansible_host=stapp02.stratos.xfusioncorp.com ansible_password=Am3ric@
stapp03 ansible_connection=ssh ansible_user=banner ansible_host=stapp03.stratos.xfusioncorp.com ansible_password=BigGr33n
stlb01 ansible_connection=ssh ansible_user=loki ansible_host=stlb01.stratos.xfusioncorp.com ansible_password=Mischi3f
stdb01 ansible_connection=ssh ansible_user=peter ansible_host=stdb01.stratos.xfusioncorp.com ansible_password=Sp!dy
ststor01 ansible_connection=ssh ansible_user=natasha ansible_host=ststor01.stratos.xfusioncorp.com ansible_password=Bl@kW
stbkp01 ansible_connection=ssh ansible_user=clint ansible_host=stbkp01.stratos.xfusioncorp.com ansible_password=H@wk3y3
stmail01 ansible_connection=ssh ansible_user=groot ansible_host=stmail01.stratos.xfusioncorp.com ansible_password=Gr00T123
jump_host ansible_connection=ssh ansible_user=thor ansible_host=jump_host.stratos.xfusioncorp.com ansible_password=mjolnir123
jenkins ansible_connection=ssh ansible_user=jenkins ansible_host=jenkins.stratos.xfusioncorp.com ansible_password=j@rv!s
Since this is a fake network on a public site, I don’t think that will be a problem. If anybody sees an error in it, please tell me, since I want to fix it.
OK, found a few problems. This one appears to work, though. You need to have an ansible.cfg file that contains
[default]
host_key_check=False
And the winning inventory file is
stapp01 ansible_connection=ssh ansible_user=tony ansible_host=stapp01.stratos.xfusioncorp.com ansible_sudo_pass=Ir0nM@n ansible_ssh_pass=Ir0nM@n
stapp02 ansible_connection=ssh ansible_user=steve ansible_host=stapp02.stratos.xfusioncorp.com ansible_sudo_pass=Am3ric@ ansible_ssh_pass=Am3ric@
stapp03 ansible_connection=ssh ansible_user=banner ansible_host=stapp03.stratos.xfusioncorp.com ansible_sudo_pass=BigGr33n ansible_ssh_pass=BigGr33n
stlb01 ansible_connection=ssh ansible_user=loki ansible_host=stlb01.stratos.xfusioncorp.com ansible_sudo_pass=Mischi3f ansible_ssh_pass=Mischi3f
stdb01 ansible_connection=ssh ansible_user=peter ansible_host=stdb01.stratos.xfusioncorp.com ansible_sudo_pass=Sp!dy ansible_ssh_pass=Sp!dy
ststor01 ansible_connection=ssh ansible_user=natasha ansible_host=ststor01.stratos.xfusioncorp.com ansible_sudo_pass=Bl@kW ansible_ssh_pass=Bl@kW
stbkp01 ansible_connection=ssh ansible_user=clint ansible_host=stbkp01.stratos.xfusioncorp.com ansible_sudo_pass=H@wk3y3 ansible_ssh_pass=H@wk3y3
stmail01 ansible_connection=ssh ansible_user=groot ansible_host=stmail01.stratos.xfusioncorp.com ansible_sudo_pass=Gr00T123 ansible_ssh_pass=Gr00T123
jump_host ansible_connection=ssh ansible_user=thor ansible_host=jump_host.stratos.xfusioncorp.com ansible_sudo_pass=mjolnir123 ansible_ssh_pass=mjolnir123
jenkins ansible_connection=ssh ansible_user=jenkins ansible_host=jenkins.stratos.xfusioncorp.com ansible_sudo_pass=j@rv!s ansible_ssh_pass=j@rv!s
Great, its all good now, Thanks Rob.