-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load ansible.cfg in each playbook dir #10398
Comments
That's right, so the top-level config of a project is used in job runs. This is a known pain point. If you have any ideas for a natural way to configure a different config, I would like to hear them. |
To sum up, I have this architecture and I need to load specific ansible.cfg when I execute deploy_manager.yml or deploy_manager2.yml When I execute the playbook from the ansible-playbook cli, this is the ansible.cfg in current directory which is loaded according to the documentation:
Now when I setup a template in AWX, the current directory is not the playbook directory but the top level project with no ansible.cfg or a global ansible.cfg. I don't know how difficult it could be to add this check ? Another option could be to set the ANSIBLE_CONFIG to a variable set by AWX at job execution. I saw AWX_PRIVATE_DATA_DIR set to "tmp/cev039fj/awx_1900_tw78u5vh/project" but maybe there is another variable which contains playbook path ? What do you think about it ? |
Yes, that's valid. Such a flag doesn't seem like a good fit for job templates to me. Why would you have a playbook in directory A and then use a config in directory B? Maybe this is common and I just don't get it.
Yeah, I get it. Implementation isn't difficult. This could be done by either setting the working directory or ANSIBLE_CONFIG, as you mention. We just don't want the behavior to be a surprise. |
Yeah I understand your point. Not really usefull for other case just to load a specific ansible.cfg in playbook path.
With working directory, you mean add a Add a location for ANSIBLE_CONFIG is less destructive because if there is no, ansible will just check /etc/ansible/ansible.cfg For example: |
BTW, I have setup an ansibe.cfg at the root project, it gets loaded. ansible.cfg and my ansible.cfg config:
I have the callback_plugins folder next to ansible.cfg but when I execute the job, I have
What I did wrong ? -> EDIT :(
All I want was to load a plugin that print the stdout shell log in real time so I have to edit stdout callback ahah ^^ However, the plugin should have loaded because I set it in the ansible.cfg
Another way is with ansible callback plugin settings but there is an issue A good point could be to create a documentation about how to migrate ansible architecture folder to awx architecture folder because there are a lof of things that ansible is working but awx not ^^ |
plugin directories (and other configuration paths) are always relative to the playbook itself, not to the ansible.cfg location. Imagine the configuration being set in /etc/ansible/ansible.cfg - relative to that wouldn't make sense. |
Yeah I understand your point of view for /etc/ansible/ansibe.cfg which is the default PATH. Now when I config a specific ansible.cfg file, I expect that all relative path configure in it which start from ansible.cfg path. But nevermind, Change stdout callback is not possible. I learned some point about how awx works so it's cool. Thanks |
Okay, I know that But the issue is that you didn't set the env var However, AWX does read the config file in cases, so that it doesn't clobber the user settings. This is the wrong place to do it. That needs to be moved into There is 1 other way we could fix this - we could put the You are also setting the stdout callback setting. This doesn't make a lot of sense to me. There can only be 1 standard out callback plugin, because that's what dictates what gets written to standard out. I toyed with ideas for layering them, but they would step on each other's toes. Instead, I think you should consider doing your plugin as a "normal" callback plugin instead of a stdout callback plugin. If you do this, you can still enable it by changing the |
OK thanks for your explanation. I close |
Hi all, I want to achieve the same thing, load
From what I understand from your discussion, I can be able to do that by setting an environment variable at playbook execution, but it does not seem to be working. Here is my test playbook :
P.S. : I also tried to set :
on the If someone has a solution it would be great ! |
Did you get a solution for this? |
Unfortunately no... |
I didn't find a way for AWX, I have only one ansible.cfg in project root folder and I keep each ansible.cfg in playbook folder when I execute ansible in CLI. |
But let me explain the issue. #playbooks └── web├── README.md├── defaults│ └── main.yml├── files├── handlers│ └── main.yml├── meta│ └── main.yml├── tasks│ └── main.yml├── templates├── tests│ ├── inventory│ └── test.yml└── vars└── main.ymlHowever in the job task ansible-playbook 2.9.18 |
ISSUE TYPE
SUMMARY
Hello,
I'm looking for a solution to load local ansible.cfg at root playbook_dir.
This is my architeture folder of playbooks:
ansible
├── deploy_manager
│ ├── ansible.cfg
│ ├── deploy_manager.yml
│ ├── environments
│ │ ├── demo
│ │ │ ├── group_vars
│ │ │ │ └── demo.yml
│ │ │ ├── inventory.yml
│ │ │ └── vars
│ │ │ └── vault.yml
│ │ ├── int
│ │ │ ├── group_vars
│ │ │ │ └── int.yml
│ │ │ ├── inventory.yml
│ │ │ └── vars
│ │ │ └── vault.yml
│ │ └── prod
│ │ ├── group_vars
│ │ │ └── prod.yml
│ │ ├── inventory.yml
│ │ └── vars
│ │ └── vault.yml
│ ├── README.md
│ └── roles
│ ├── create_instance
│ │ └── tasks
│ │ └── main.yml
When I execute the playbook with ansible-playbook cli, I have an ansible.cfg in current dir so ansible.cfg is loaded.
When I execute the playbook from AWX, the project is in tmp/cev039fj/awx_1900_tw78u5vh/project.
There is no ansible.cfg in /tmp/ cev039fj/awx_1900_tw78u5vh so it's the /etc/ansible/ansible.cfg which is loaded.
I have an ansible.cfg in each playbook directory with different params so how could I setup the ANSIBLE_CONFIG path to playbook dir ansible.cfg when a playbook is launched by AWX ?
I did some tests unsuccessful with ANSIBLE_CONFIG setup.
Have you any ideas ?
ENVIRONMENT
The text was updated successfully, but these errors were encountered: