Skip to content

Commit

Permalink
Add code to unmount /etc/resolv.conf in Molecule prepare stage
Browse files Browse the repository at this point in the history
Docker bind mounts a file from the host to /etc/resolv.conf.  This is
inconvenient for us, since we need to create a symlink at
/etc/resolv.conf.  At the same time, we don't want to break DNS.  The
playbook being imported contains a workaround for this situation.
  • Loading branch information
jsf9k committed May 3, 2024
1 parent b3bc1ee commit 6b5a0d8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
- name: Import upgrade playbook
ansible.builtin.import_playbook: upgrade.yml

# Docker bind mounts a file from the host to /etc/resolv.conf. This
# is inconvenient for us, since we need to create a symlink at
# /etc/resolv.conf. At the same time, we don't want to break DNS.
# The playbook being imported contains a workaround for this
# situation.
- name: Unmount /etc/resolv.conf
ansible.builtin.import_playbook: unmount.yml
26 changes: 26 additions & 0 deletions molecule/default/unmount.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Unmount /etc/resolv.conf
hosts: all
become: true
become_method: ansible.builtin.sudo
tasks:
- name: Copy /etc/resolv.conf to /tmp
ansible.builtin.copy:
dest: /tmp/resolv.conf
group: root
mode: u=rw,g=r,o=r
owner: root
remote_src: true
src: /etc/resolv.conf
- name: Unmount /etc/resolv.conf
ansible.posix.mount:
path: /etc/resolv.conf
state: unmounted
- name: Copy /tmp/resolv.conf to /etc
ansible.builtin.copy:
dest: /etc/resolv.conf
group: root
mode: u=rw,g=r,o=r
owner: root
remote_src: true
src: /tmp/resolv.conf

0 comments on commit 6b5a0d8

Please sign in to comment.