Skip to content

Commit

Permalink
Revert "podman: remove ansible_async_dir setting logic (#182)"
Browse files Browse the repository at this point in the history
This reverts commit 0244719.

Signed-off-by: Wong Hoi Sing Edison <[email protected]>
  • Loading branch information
hswong3i committed Jan 23, 2025
1 parent 613b885 commit 1e38e92
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/molecule_plugins/podman/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
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: >-
{{ _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
containers.podman.podman_login:
certdir: >-
Expand Down
18 changes: 18 additions & 0 deletions src/molecule_plugins/podman/playbooks/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
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: >-
{{ _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"
register: server
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ passenv =
SSL_CERT_FILE
TOXENV
TWINE_*
USER
OS_*
allowlist_externals =
bash
Expand Down

0 comments on commit 1e38e92

Please sign in to comment.