Ansible Inventory Update and Ansible Copy Module Tasks are Failed even with correct inventory files

@mmumshad @KodeKloud @Inderpreet @kodekloud-support3

Ansible Inventory Update and Ansible Copy Module Tasks are Failed even with correct inventory files.

Can anyone please guide me if you have attempted in these tasks, and what was your inventory file?

In both tasks I was able to run playbooks without any error and services were started.

But tasks failed with below error :slight_smile:

- file '/home/thor/playbook/inventory' does not exist on Jump Server

My Inventory.ini:

thor@jump_host ~/ansible$ cat inventory

[appsservers]

stapp01 ansible_user=tony ansible_password=Ir0nM@n

thor@jump_host ~/ansible$

from you prompt on jump_host, I feel your inventory file is under /home/thor/ansible and not under /home/thor/playbook. Can you run pwd and confirm directory location where inventory file is placed.

@smartclick Thanks for your reply.

As we can see below, all my files are under β€œ/home/thor/playbook/” dir.

thor@jump_host /$ cd /home/thor/playbook/
thor@jump_host ~/playbook$ ls
ansible.cfg inventory.ini playbook.yml 
thor@jump_host ~/playbook$
thor@jump_host ~/playbook$ cat inventory.ini
[appsservers]
stapp01 ansible_user=tony ansible_password=Ir0nM@n
thor@jump_host ~/playbook$

Able to run playbook succefully:

thor@jump_host ~/playbook$ ansible-playbook -i inventory.ini playbook.yml

PLAY [all] ***************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************
ok: [stapp03]

TASK [Install httpd package] *********************************************************************************************
changed: [stapp03]

TASK [Start service httpd] ***********************************************************************************************
changed: [stapp03]

PLAY RECAP ***************************************************************************************************************
stapp03                    : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

thor@jump_host ~/playbook$

HTTPd service also started successfully:

[root@stapp03 banner]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)   Active: active (running) since Thu 2020-07-02 05:31:48 UTC; 46s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 430 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /docker/9910ac515aa99d856bbc8a3f9da7f0531a45e791ec893e8768f1584e44b335bc/system.slice/httpd.service
           β”œβ”€430 /usr/sbin/httpd -DFOREGROUND
           β”œβ”€431 /usr/sbin/httpd -DFOREGROUND
           β”œβ”€432 /usr/sbin/httpd -DFOREGROUND
           β”œβ”€433 /usr/sbin/httpd -DFOREGROUND
           β”œβ”€434 /usr/sbin/httpd -DFOREGROUND
           └─435 /usr/sbin/httpd -DFOREGROUND

Jul 02 05:32:07 stapp03 systemd[1]: httpd.service: got READY=1
Jul 02 05:32:07 stapp03 systemd[1]: httpd.service: got STATUS=Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec
Jul 02 05:32:17 stapp03 systemd[1]: Got notification message for unit httpd.service
Jul 02 05:32:17 stapp03 systemd[1]: httpd.service: Got notification message from PID 430 (READY=1, STATUS=Total requests:0; Current requests/sec: 0; Current traffic:   0 B/sec)
Jul 02 05:32:17 stapp03 systemd[1]: httpd.service: got READY=1
Jul 02 05:32:17 stapp03 systemd[1]: httpd.service: got STATUS=Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec
Jul 02 05:32:27 stapp03 systemd[1]: Got notification message for unit httpd.service
Jul 02 05:32:27 stapp03 systemd[1]: httpd.service: Got notification message from PID 430 (READY=1, STATUS=Total requests:0; Current requests/sec: 0; Current traffic:   0 B/sec)
Jul 02 05:32:27 stapp03 systemd[1]: httpd.service: got READY=1
Jul 02 05:32:27 stapp03 systemd[1]: httpd.service: got STATUS=Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec
[root@stapp03 banner]#

Any idea why its failed with β€œ- file β€˜/home/thor/playbook/inventory’ does not exist on Jump Server” error?

Hi,
The ansible inventory ini type does not mean the inventory should have .ini extension. For this question, it was specified to be /home/thor/playbook/inventory not /home/thor/playbook/inventory.ini.
it can still be inventory. The ini type is basically what you did right.
The KK job did not find the inventory file that is why. So basically you were right buh the file name of the inventory file.
thanks

1 Like