Kode kloud engineer level 1 - challenge 1 Ansible Troubleshoot and Create Ansible Playbook

What did I do wrong here :

ansible all -a "ls -ltr /tmp/" -i inventory
stapp01 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: tony@172.16.238.10: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
    "unreachable": true
}
stapp02 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: ssh: connect to host 172.238.16.204 port 22: Connection timed out",
    "unreachable": true
}
thor@jumphost ~/ansible$ cat inventory 
stapp02 ansible_host=172.238.16.204 ansible_user=steve  ansible_ssh_pass=Am3ric@  ansible_ssh_common_args='-o StrictHostKeyChecking=no'
stapp01 ansible_host=172.16.238.10  ansible_user=tony ansible_ssh_common_args='-o StrictHostKeyChecking=no'

Hi @rwobben

I think you also need to generate SSH keys and copy them to App Server2.

oke

I can do that this way

ssh-copy-id -i ~/.ssh/mykey user@host

Generate SSH keys using the default key names: id_rsa.

do this steps.
step1: vi /home/thor/ansible/inventory
then add according to the given server like if given app server1 -
“stapp01 ansible_host=172.16.238.10 ansible_user=tony ansible_ssh_pass=Ir0nM@n”
save and exit
step2: vi /home/thor/ansible/playbook.yml
then add this

- name: Create a file appserver
hosts: stapp01
become: yes
tasks:
- name: Create the file
file:
path: /tmp/file.txt
state: touch
save and exit.
step3: cd /home/thor/ansible
step4: run this command - ansible-playbook -i inventory playbook.yml
it will successfully created the file in the appserver.