I’m running an Ansible project on AWX and have encountered an issue related to folder creation during task execution. Specifically, I need to create a config folder during the execution of my playbook, which will be used to store router and switch configurations for later application.
While the job execution in AWX shows as successful, the config folders are not visible in the expected location. I have a persistent volume mounted on my AWX server at /var/lib/awx/projects, which is also visible within the container pods.
Here’s what I’ve tried:
Created directories using the Ansible file module.
Verified that the persistent volume is correctly mounted and accessible from within the container.
Despite these efforts, the folders created during the job are not appearing as expected.
Has anyone encountered a similar issue or have suggestions on how to resolve this?
Thank you for your assistance!
Best regards,
Bayet
pb_create_folder.yml
name: Create and persist config directory
hosts: dc1,dc2
tasks:
I see you’re using delegate_to: localhost in your code, that means the tasks are delegated to the container running your job in AWX.
AWX exclusively uses Execution Environments to run jobs, which means that the folders are created in the ephemeral container and are destroyed with the container after the job has concluded.
If you need/want to have files stored, you’ll need to delegate these tasks to a different machine
I solved this issue by creating a Persistent Volume (PV) and a container instance group in AWX. In the job settings, I configured the job to use this new container group while executing. Since the job runs in the new container, which is bound to the PV, the folder and files are created and accessible after job execution.