Merge "Fixed the upgrade script edge case"

This commit is contained in:
Jenkins 2015-07-03 17:25:08 +00:00 committed by Gerrit Code Review
commit 013e344c74

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