Finish lxc container and lxc host resources

This commit is contained in:
Dmitry Shulyak 2015-08-03 18:04:05 +03:00
parent f6b7cf7843
commit 88f2ba4725
5 changed files with 36 additions and 30 deletions

View File

@ -1,32 +1,25 @@
- hosts: '*' - hosts: '*'
sudo: yes sudo: yes
gather_facts: false gather_facts: false
# this is default variables, they will be overwritten by resource one # this is default variables, they will be overwritten by resource one
vars: vars:
ansible_ssh_host: 10.0.0.4 ansible_ssh_host: 10.0.0.3
container_name: test2 physical_host: 10.0.0.3
inventory_hostname: test2 container_name: test3
inventory_hostname: test3
properties:
container_release: trusty
container_networks: container_networks:
mgmt: mgmt:
address: 172.18.10.5 address: 172.18.10.6
bridge: br-test0 bridge: br-test0
bridge_address: 172.18.10.253/24 bridge_address: 172.18.10.252/24
interface: eth1 interface: eth1
netmask: 255.255.255.0 netmask: 255.255.255.0
type: veth type: veth
physical_host: 10.0.0.4 pub_key: ''
properties:
container_release: trusty
pre_tasks: pre_tasks:
- shell: pip install git+https://github.com/lxc/python2-lxc.git#egg=lxc - set_fact:
- shell: ip l add {{item.value.bridge}} type bridge lxc_container_ssh_key: "{{ lookup('file', pub_key) }}"
with_dict: container_networks
ignore_errors: true
- shell: ip l set {{item.value.bridge}} up
with_dict: container_networks
- shell: ip a add dev {{item.value.bridge}} {{item.value.bridge_address}}
with_dict: container_networks
ignore_errors: true
roles: roles:
- { role: "lxc_container_create", tags: [ "lxc-container-create" ] } - { role: "lxc_container_create", tags: [ "lxc-container-create" ] }

View File

@ -1,10 +0,0 @@
- stat: path=/tmp/os-ansible-deployment
register: repo
- git: repo=https://github.com/stackforge/os-ansible-deployment.git
dest=/tmp/os-ansible-deployment
when: repo.stat.exists == False
- shell: cp -r /tmp/os-ansible-deployment/playbooks/roles/{{item}} /etc/ansible/roles/
with_items:
- lxc_container_create
- lxc_container_destroy

View File

@ -15,12 +15,30 @@ input:
ansible_ssh_host: ansible_ssh_host:
schema: str! schema: str!
value: value:
physical_host:
schema: str!
value:
container_address: container_address:
schema: str! schema: str!
value: value:
container_name: container_name:
schema: str! schema: str!
value: value:
inventory_hostname:
schema: str!
value:
container_networks:
schema: {}
value:
properties:
schema: {}
value:
pub_key:
schema: str!
value:
requires:
schema: str
value:
roles: roles:
schema: [{value: str}] schema: [{value: str}]
value: value:

View File

@ -2,3 +2,5 @@
sudo: yes sudo: yes
roles: roles:
- { role: "lxc_hosts", tags: [ "lxc-host", "host-setup" ] } - { role: "lxc_hosts", tags: [ "lxc-host", "host-setup" ] }
post_tasks:
- shell: pip install git+https://github.com/lxc/python2-lxc.git#egg=lxc

View File

@ -12,6 +12,9 @@ input:
ssh_user: ssh_user:
schema: str! schema: str!
value: value:
provides:
schema: str
value: infra
roles: roles:
schema: [{value: str}] schema: [{value: str}]
value: value: