Skip to content

Commit 4e9080f

Browse files
committed
Add code to unmount /etc/resolv.conf in Molecule prepare stage
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.
1 parent 35a37f6 commit 4e9080f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

molecule/default/prepare.yml

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
---
22
- name: Import upgrade playbook
33
ansible.builtin.import_playbook: upgrade.yml
4+
5+
# Docker bind mounts a file from the host to /etc/resolv.conf. This
6+
# is inconvenient for us, since we need to create a symlink at
7+
# /etc/resolv.conf. At the same time, we don't want to break DNS.
8+
# The playbook being imported contains a workaround for this
9+
# situation.
10+
- name: Unmount /etc/resolv.conf
11+
ansible.builtin.import_playbook: unmount.yml

molecule/default/unmount.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
- name: Unmount /etc/resolv.conf
3+
hosts: all
4+
become: true
5+
become_method: ansible.builtin.sudo
6+
tasks:
7+
- name: Copy /etc/resolv.conf to /tmp
8+
ansible.builtin.copy:
9+
dest: /tmp/resolv.conf
10+
group: root
11+
mode: u=rw,g=r,o=r
12+
owner: root
13+
remote_src: true
14+
src: /etc/resolv.conf
15+
- name: Unmount /etc/resolv.conf
16+
ansible.posix.mount:
17+
path: /etc/resolv.conf
18+
state: unmounted
19+
- name: Copy /tmp/resolv.conf to /etc
20+
ansible.builtin.copy:
21+
dest: /etc/resolv.conf
22+
group: root
23+
mode: u=rw,g=r,o=r
24+
owner: root
25+
remote_src: true
26+
src: /tmp/resolv.conf

0 commit comments

Comments
 (0)