Closed namsic closed 1 month ago
Can I just add the same change to every roles?
fix: ensure binary_install_dir before copy binary
Or should I do something else?
Can I just add the same change to every roles?
fix: ensure binary_install_dir before copy binary
Or should I do something else?
You can add a task to the install tasks file of the _common
role which all the roles use.
Adding this task before the last task, the one named "Propagate binaries", in _common/tasks/install.yml
would probably do the trick.
- name: "Make sure binary install dir exists"
ansible.builtin.file:
path: "{{ _common_binary_install_dir }}"
mode: 0755
owner: root
group: root
become: true
tags:
- "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}"
- install
- "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}_install"
Thanks for the detailed explanation. I changed it according to your comment.
I think we should use ansible.bultin.stat as a preflight check, rather than actually try and create the target directory.
Can someone help me?
I can't figure out how my ansible.builtin.stat
changes relate to the error below.
INFO Running alternative > destroy
INFO Sanity checks: 'docker'
[WARNING]: Collection community.docker does not support Ansible version
2.11.12.post0
PLAY [Destroy] *****************************************************************
TASK [Destroy molecule instance(s)] ********************************************
fatal: [localhost]: FAILED! => {
"msg": "Could not find imported module support code for ansible_collections.community.docker.plugins.modules.docker_container.
Looked for (['ansible.module_utils.compat.version.LooseVersion', 'ansible.module_utils.compat.version'])"
}
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
WARNING Retrying execution failure 2 of: ansible-playbook --inventory /root/.cache/molecule/alertmanager/alternative/inventory --skip-tags molecule-notest,notest /usr/local/lib/python3.6/dist-packages/molecule_docker/playbooks/destroy.yml
CRITICAL Ansible return code was 2, command was: ['ansible-playbook', '--inventory', '/root/.cache/molecule/alertmanager/alternative/inventory', '--skip-tags', 'molecule-notest,notest', '/usr/local/lib/python3.6/dist-packages/molecule_docker/playbooks/destroy.yml']
Can someone help me?
I can't figure out how my
ansible.builtin.stat
changes relate to the error below.INFO Running alternative > destroy INFO Sanity checks: 'docker' [WARNING]: Collection community.docker does not support Ansible version 2.11.12.post0 PLAY [Destroy] ***************************************************************** TASK [Destroy molecule instance(s)] ******************************************** fatal: [localhost]: FAILED! => { "msg": "Could not find imported module support code for ansible_collections.community.docker.plugins.modules.docker_container. Looked for (['ansible.module_utils.compat.version.LooseVersion', 'ansible.module_utils.compat.version'])" } PLAY RECAP ********************************************************************* localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 WARNING Retrying execution failure 2 of: ansible-playbook --inventory /root/.cache/molecule/alertmanager/alternative/inventory --skip-tags molecule-notest,notest /usr/local/lib/python3.6/dist-packages/molecule_docker/playbooks/destroy.yml CRITICAL Ansible return code was 2, command was: ['ansible-playbook', '--inventory', '/root/.cache/molecule/alertmanager/alternative/inventory', '--skip-tags', 'molecule-notest,notest', '/usr/local/lib/python3.6/dist-packages/molecule_docker/playbooks/destroy.yml']
That issue is unrelated to your change, the docker ansible collection which is used for the tests was updated recently and that broke compatibility with old ansible versions. I fixed the issue in #440
Thank you for contribution!✨
This PR has been merged and the docs are now incorporated into main
:
https://prometheus-community.github.io/ansible/branch/main
I'm trying to install node_exporter on a remote host with a custom
node_exporter_binary_install_dir
.But when I ran the above playbook, I got the following result:
If there are multiple target hosts, it would be nice to automatically create the directory if it does not exist.
If these changes are not appropriate, please let me know.
Thanks.