Browse Source

It seems like python3-lxc solve smy problems

master
Simon Vikstrom 11 months ago
parent
commit
f8b3dfd665
2 changed files with 13 additions and 15 deletions
  1. +1
    -0
      ansible.cfg
  2. +12
    -15
      roles/lxchost/tasks/main.yml

+ 1
- 0
ansible.cfg View File

@@ -1,2 +1,3 @@
[defaults]
inventory = inventory
remote_user = root

+ 12
- 15
roles/lxchost/tasks/main.yml View File

@@ -6,38 +6,33 @@
'python2.7-dev',
'python-virtualenv',
'debootstrap',
'python-lxc',
'python3-lxc',
'lxc-templates']
state: latest
tags:
- lxc

- name: Install required lxc-python2 Python package
pip:
name: lxc-python2
state: present
virtualenv_python: python2.7
virtualenv: '$HOME/virtualenv/python2.7'
become: no
register: out
until: out is succeeded
retries: 30

- name: Config lxc network
template:
dest: '/etc/default/lxc-net'
src: 'lxc-net.j2'
register: service_conf
tags:
- lxc

- name: restart service
service:
name: lxc-net
state: restarted
when: service_conf.changed
tags:
- lxc

- name: Load in local SSH key path
set_fact:
my_ssh_key: "{{ lookup('env','HOME') }}/.ssh/authorized_keys"
tags:
- lxc

- name: Install containers
lxc_container:
@@ -46,9 +41,9 @@
container_config:
- "lxc.net.0.type = veth"
- "lxc.net.0.flags = up"
- "lxc.net.0.link = {{ lxc_config.bridge_ifname }}"
- "lxc.net.0.ipv4.address = {{item.value.ipv4_address}}"
- "lxc.net.0.ipv4.gateway = {{item.value.ipv4_gateway}}"
- "lxc.net.0.link = {{ lxc_config.bridge_ifname | string }}"
- "lxc.net.0.ipv4.address = {{item.value.ipv4_address | string }}"
- "lxc.net.0.ipv4.gateway = {{item.value.ipv4_gateway | string }}"
container_command: |
if [ ! -d ~/.ssh ]; then
mkdir ~/.ssh
@@ -61,3 +56,5 @@
environment:
DEBIAN_FRONTEND: noninteractive
with_dict: '{{ lxc_containers }}'
tags:
- lxc

Loading…
Cancel
Save