Skip to content
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

podman: change ansible_async_dir only when $HOME is redefined #173

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/molecule_plugins/podman/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@
ansible.builtin.set_fact:
podman_cmd: "{{ _podman_path.stdout }}"

- name: Get passwd entries for USER env
ansible.builtin.getent:
database: passwd
key: "{{ lookup('env', 'USER') }}"

- name: Get shell async_dir
ansible.builtin.set_fact:
_shell_async_dir: >-
{{ lookup('ansible.builtin.config', 'async_dir', plugin_type='shell', plugin_name='sh')
| regex_replace('^~', ansible_facts.getent_passwd[lookup('env', 'USER')][4]) }}

- name: Set async_dir for HOME env
ansible.builtin.set_fact:
ansible_async_dir: "{{ lookup('env', 'HOME') }}/.ansible_async/"
when: (lookup('env', 'HOME'))
ansible_async_dir: >-
{{ _shell_async_dir
| regex_replace('^' + ansible_facts.getent_passwd[lookup('env', 'USER')][4], lookup('env', 'HOME')) }}
when: lookup('env', 'HOME') != ansible_facts.getent_passwd[lookup('env', 'USER')][4]

- name: Log into a container registry
ansible.builtin.command: >
Expand Down
17 changes: 15 additions & 2 deletions src/molecule_plugins/podman/playbooks/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@
vars:
podman_exec: "{{ lookup('env','MOLECULE_PODMAN_EXECUTABLE')|default('podman',true) }}"
tasks:
- name: Get passwd entries for USER env
ansible.builtin.getent:
database: passwd
key: "{{ lookup('env', 'USER') }}"

- name: Get shell async_dir
ansible.builtin.set_fact:
_shell_async_dir: >-
{{ lookup('ansible.builtin.config', 'async_dir', plugin_type='shell', plugin_name='sh')
| regex_replace('^~', ansible_facts.getent_passwd[lookup('env', 'USER')][4]) }}

- name: Set async_dir for HOME env
ansible.builtin.set_fact:
ansible_async_dir: "{{ lookup('env', 'HOME') }}/.ansible_async/"
when: (lookup('env', 'HOME'))
ansible_async_dir: >-
{{ _shell_async_dir
| regex_replace('^' + ansible_facts.getent_passwd[lookup('env', 'USER')][4], lookup('env', 'HOME')) }}
when: lookup('env', 'HOME') != ansible_facts.getent_passwd[lookup('env', 'USER')][4]

- name: Destroy molecule instance(s)
ansible.builtin.shell: "{{ podman_exec }} container exists {{ item.name }} && {{ podman_exec }} rm -f {{ item.name }} || true"
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ passenv =
SSL_CERT_FILE
TOXENV
TWINE_*
USER
allowlist_externals =
bash
twine
Expand Down