Hello All,
I am importing all the hosts inside my hosts file into AWX using awx-manage commands like
-
docker exec -it awx_task bash
-
cd /var/lib/awx/projects/ansible
-
awx-manage inventory_import --source=./hosts --inventory-name="Manual Project Inventory" --overwrite --overwrite-vars
And its working fine as expected it is importing all the hosts inside AWX inventory
But instead of manually running it, I want it to do through ansible playbook. I have written one. But when i am running it. It shows status as changed and completes successfully.
But the inventory is not getting updated in the AWX. Below is my playbook, can anyone please tell me what i am doing wrong or what to be done or some other script will also be fine for me.
**First Playbook**
---
- hosts: localhost
tasks:
- name: Execute commands in docker container
command: docker exec -it awx_task bash -c awx-manage inventory_import --source=/var/lib/awx/projects/ansible/hosts --inventory-name="Manual Project Inventory" --overwrite --overwrite-vars
**Second Playbook**
**---**
- hosts: localhost
tasks:
- name: This command will change the working directory to somedir/
shell:
cmd: awx-manage inventory_import --source=/var/lib/awx/projects/ansible/hosts --inventory-name="Manual Project Inventory" --overwrite --overwrite-vars
args:
executable: docker exec -it awx_task bash
Please help me if someone has any idea.
Thanks in advance.
``