Use connection plugin instead of delegating

As of 2.2.3.0, Ansible now expands and follows the real paths of the
symlinks. Attempting the expand the symlink of /root within a
container's /proc directory becomes unreachable. Instead of delegating
to containers' physical host and writing files to containers through
/proc, make use of the OSA ssh connection plugin.

Closes-Bug: 1696802
Change-Id: I79658a261613357b610f481187868a1eed56b5a3
This commit is contained in:
Jimmy McCrory 2017-06-19 07:51:32 -07:00
parent 4469f859a6
commit 8ded80fdc9
1 changed files with 4 additions and 21 deletions

View File

@ -259,31 +259,21 @@
tags:
- lxc_container_create-create
- name: Get LXC container PID
command: >
lxc-info -pHn {{ inventory_hostname }}
register: container_pid
changed_when: false
delegate_to: "{{ physical_host }}"
tags:
- lxc_container_create-setup
- name: Drop container network file (interfaces)
template:
src: "{{ lxc_container_interface }}"
dest: "/proc/{{ container_pid.stdout }}/root{{ lxc_container_interface_target }}"
dest: "{{ lxc_container_interface_target }}"
owner: "root"
group: "root"
mode: "0644"
with_dict: "{{ container_networks | default({}) }}"
delegate_to: "{{ physical_host }}"
tags:
- lxc_container_create-setup
- name: Drop container network file (routes)
template:
src: "{{ lxc_container_route_interface }}"
dest: "/proc/{{ container_pid.stdout }}/root{{ lxc_container_default_route_interfaces }}"
dest: "{{ lxc_container_default_route_interfaces }}"
owner: "root"
group: "root"
mode: "0644"
@ -293,31 +283,24 @@
- item.value.static_routes is defined or
(item.value.gateway is defined and ansible_pkg_mgr == "zypper")
with_dict: "{{ container_networks | default({}) }}"
delegate_to: "{{ physical_host }}"
tags:
- lxc_container_create-setup
- name: Drop container setup script
template:
src: "container-setup.sh.j2"
dest: "/proc/{{ container_pid.stdout }}/root/opt/container-setup.sh"
dest: "/opt/container-setup.sh"
owner: "root"
group: "root"
mode: "0755"
delegate_to: "{{ physical_host }}"
tags:
- lxc_container_create-setup
- name: Run container setup script
command: |
lxc-attach --name "{{ inventory_hostname }}" \
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log \
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }} \
-- /opt/container-setup.sh
command: /opt/container-setup.sh
register: container_setup
changed_when: false
failed_when: container_setup.rc != 0
delegate_to: "{{ physical_host }}"
tags:
- lxc_container_create-setup