Open foto-andreas opened 1 month ago
Adding my idea:
// in project directory
for (p in ProjectManager.getInstance().openProjects) {
for (r in ProjectRootManager.getInstance(p).contentRoots) {
getPasswordFilePathFromConfig(r.path + "/ansible.cfg")
?.let { return r.path + "/" + it }
}
break;
}
// in current directory
getPasswordFilePathFromConfig("ansible.cfg")
?.let { return File(it).absolutePath }
Beware. I have no idea on the correct IJ-APIs to use, but this solution works for me.
Open:
Andreas
working on pull request #304 on it
In our company we use to have all ansible files under subdirectory, this PR can support this? Eg:
[root]/ansible/ansible.cfg
or
[root]/infrastructure/ansible/ansible.cfg
not currently, only if the vaulted files are also in that directory. how will ansible-playbook find these files when called?
Simply we have a Makefile with a target like this:
deploy: build
ANSIBLE_CONFIG=ansible/ansible.cfg ansible-playbook \
--private-key ~/.ssh/superkey.pem \
-i ansible/inventories/prod/hosts \
--user admin \
ansible/main.yml
or simple cd and execute the playbook
Ah, ANSIBLE_CONFIG environment variable. I think this is already supported. just place vault_password_file property in the ansible.cfg or set a second environment variable ANSIBLE_VAULT_PASSWORD_FILE to the password file path.
How to configure IDEA with ANSIBLE_CONFIG? I don't know.
How to configure IDEA with ANSIBLE_CONFIG? I don't know.
Hi 👋!
You can set an environment variable on the system level, like for the default tool.
@foto-andreas, thanks for the issue. I really forgot about that to-do.
I'm trying to stick with the default locations from Ansible documentation, but even complex setups supported using a password file with a script, where we can do literally anything.
How to configure IDEA with ANSIBLE_CONFIG? I don't know.
Hi 👋!
You can set an environment variable on the system level, like for the default tool.
Yes and no... Because I need to set multiple time environment variable (that is global) once for each project I open, and sometimes I open 2 to 4 projects, at same time, all with ansible inside (and a lot of other things), and sometimes ansible.cfg files are under a path or sometimes under some "funky" path. And cherry on the cacke, each project has a different vault password file. So I can specify the ansible.cfg file position per project or can be done a sort of a discovery on project paths/index.
What do you think?
Hi,
is this only a forgotten TODO or did you encounter problems implementing the usage of ansible.config in current directory?
Andreas