lxc : add name of container in task names
This commit is contained in:
parent
12cebfa71c
commit
16c44ab867
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
- name: Check if container exists
|
- name: "Check if container {{ name }} exists"
|
||||||
command: "lxc-ls {{name}}"
|
command: "lxc-ls {{name}}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: container_exists
|
register: container_exists
|
||||||
|
|
||||||
- name: Create container
|
- name: "Create container {{ name }}"
|
||||||
lxc_container:
|
lxc_container:
|
||||||
name: "{{name}}"
|
name: "{{name}}"
|
||||||
container_log: true
|
container_log: true
|
||||||
|
@ -12,38 +12,38 @@
|
||||||
state: stopped
|
state: stopped
|
||||||
template_options: "--arch amd64 --release {{release}}"
|
template_options: "--arch amd64 --release {{release}}"
|
||||||
|
|
||||||
- name: Disable network configuration inside container
|
- name: "Disable network configuration inside container {{ name }}"
|
||||||
replace:
|
replace:
|
||||||
name: "/var/lib/lxc/{{name}}/rootfs/etc/default/networking"
|
name: "/var/lib/lxc/{{name}}/rootfs/etc/default/networking"
|
||||||
regexp: "^#CONFIGURE_INTERFACES=yes"
|
regexp: "^#CONFIGURE_INTERFACES=yes"
|
||||||
replace: CONFIGURE_INTERFACES=no
|
replace: CONFIGURE_INTERFACES=no
|
||||||
when: lxc_network_type == "none"
|
when: lxc_network_type == "none"
|
||||||
|
|
||||||
- name: Disable interface shut down on halt inside container (Jessie container)
|
- name: "Disable interface shut down on halt inside container {{ name }} (Jessie container)"
|
||||||
lineinfile:
|
lineinfile:
|
||||||
name: "/var/lib/lxc/{{name}}/rootfs/etc/default/halt"
|
name: "/var/lib/lxc/{{name}}/rootfs/etc/default/halt"
|
||||||
line: "NETDOWN=no"
|
line: "NETDOWN=no"
|
||||||
when: lxc_network_type == "none" and release == "jessie"
|
when: lxc_network_type == "none" and release == "jessie"
|
||||||
|
|
||||||
- name: Make the container poweroff on SIGPWR sent by lxc-stop (Jessie container)
|
- name: "Make the container {{ name }} poweroff on SIGPWR sent by lxc-stop (Jessie container)"
|
||||||
file:
|
file:
|
||||||
src: /lib/systemd/system/poweroff.target
|
src: /lib/systemd/system/poweroff.target
|
||||||
dest: "/var/lib/lxc/{{name}}/rootfs/etc/systemd/system/sigpwr.target"
|
dest: "/var/lib/lxc/{{name}}/rootfs/etc/systemd/system/sigpwr.target"
|
||||||
state: link
|
state: link
|
||||||
when: release == 'jessie'
|
when: release == 'jessie'
|
||||||
|
|
||||||
- name: Configure the DNS resolvers in the container
|
- name: "Configure the DNS resolvers in the container {{ name }}"
|
||||||
copy:
|
copy:
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
src: /etc/resolv.conf
|
src: /etc/resolv.conf
|
||||||
dest: "/var/lib/lxc/{{name}}/rootfs/etc/"
|
dest: "/var/lib/lxc/{{name}}/rootfs/etc/"
|
||||||
|
|
||||||
- name: Add hostname in /etc/hosts
|
- name: "Add hostname in /etc/hosts for container {{ name }}"
|
||||||
lineinfile:
|
lineinfile:
|
||||||
name: "/var/lib/lxc/{{name}}/rootfs/etc/hosts"
|
name: "/var/lib/lxc/{{name}}/rootfs/etc/hosts"
|
||||||
line: "127.0.0.1 {{name}}"
|
line: "127.0.0.1 {{name}}"
|
||||||
|
|
||||||
- name: Fix permission on /dev
|
- name: "Fix permission on /dev for container {{ name }}"
|
||||||
lineinfile:
|
lineinfile:
|
||||||
name: "/var/lib/lxc/{{name}}/rootfs/etc/rc.local"
|
name: "/var/lib/lxc/{{name}}/rootfs/etc/rc.local"
|
||||||
line: "chmod 755 /dev"
|
line: "chmod 755 /dev"
|
||||||
|
|
Loading…
Reference in a new issue