Fixed the upgrade script edge case

Changed the command to find the containers to only look for the contianer
config file within a given directory and to only look one level deep.
This change is in response to an issue that can happen if the container
directory "/var/lib/lxc" is also a mounted file system.

Change-Id: Id39995580900e2b9d9a35435d0cfeba82075d62b
Closes-Bug: #1470571
This commit is contained in:
kevin
2015-07-01 11:17:00 -05:00
committed by Kevin Carter
parent c0ce11cc6a
commit 3e0e848181

View File

@@ -374,38 +374,38 @@ cat > /tmp/fix_host_things.yml <<EOF
user: root user: root
tasks: tasks:
- name: find containers in /var/lib/lxc - name: find containers in /var/lib/lxc
command: ls -1 /var/lib/lxc command: "find /var/lib/lxc -maxdepth 2 -type f -name 'config'"
register: containers register: containers
- name: get the basic container network - name: get the basic container network
shell: | shell: |
if [ "\$(grep '^lxc.network.name = eth0' /var/lib/lxc/{{ item }}/config)" ];then if [ "\$(grep '^lxc.network.name = eth0' {{ item }})" ];then
grep '^lxc.network.name = eth0' -A1 -B3 /var/lib/lxc/{{ item }}/config | tee /var/lib/lxc/{{ item }}/eth0.ini grep '^lxc.network.name = eth0' -A1 -B3 {{ item }} | tee {{ item | dirname }}/eth0.ini
if [ ! "\$(grep '/var/lib/lxc/{{ item }}/eth0.ini' /var/lib/lxc/{{ item }}/config)" ];then if [ ! "\$(grep '{{ item | dirname }}/eth0.ini' {{ item }})" ];then
echo 'lxc.include = /var/lib/lxc/{{ item }}/eth0.ini' | tee -a /var/lib/lxc/{{ item }}/config echo 'lxc.include = {{ item | dirname }}/eth0.ini' | tee -a {{ item }}
fi fi
fi fi
with_items: containers.stdout_lines with_items: containers.stdout_lines
- name: Remove lxc.network from base config - name: Remove lxc.network from base config
lineinfile: lineinfile:
dest: "/var/lib/lxc/{{ item }}/config" dest: "{{ item }}"
state: "absent" state: "absent"
regexp: "^lxc.network" regexp: "^lxc.network"
with_items: containers.stdout_lines with_items: containers.stdout_lines
- name: Remove add_network_interface.conf entry - name: Remove add_network_interface.conf entry
lineinfile: lineinfile:
dest: "/var/lib/lxc/{{ item }}/config" dest: "{{ item }}"
state: "absent" state: "absent"
regexp: 'add_network_interface\.conf' regexp: 'add_network_interface\.conf'
with_items: containers.stdout_lines with_items: containers.stdout_lines
- name: Remove aa_profile entries - name: Remove aa_profile entries
lineinfile: lineinfile:
dest: "/var/lib/lxc/{{ item }}/config" dest: "{{ item }}"
state: "absent" state: "absent"
regexp: '^lxc.aa_profile' regexp: '^lxc.aa_profile'
with_items: containers.stdout_lines with_items: containers.stdout_lines
- name: Remove old add_network_interface.conf file - name: Remove old add_network_interface.conf file
file: file:
path: "/var/lib/lxc/{{ item }}/add_network_interface.conf" path: "{{ item | dirname }}/add_network_interface.conf"
state: "absent" state: "absent"
failed_when: false failed_when: false
with_items: containers.stdout_lines with_items: containers.stdout_lines