commont task to create lxc vm in separete file `prepare_lxc_host`, avoid redundancy of statements in each vm-specific playbook file. Playbooks updated to import `prepare_lxc_host`: - ldap - matrix - nextcloud - projects - statuspython3
@ -1,24 +1,17 @@ | |||
--- | |||
- hosts: 'cloud' | |||
gather_facts: false | |||
tasks: | |||
- import_role: name='lxc_guest' | |||
vars: | |||
vm_name: '{{ inventory_hostname }}' | |||
vm_size: '4G' | |||
vg_name: '{{ hostvars[ansible_lxc_host]["vg_name"] }}' | |||
delegate_to: '{{ ansible_lxc_host }}' | |||
- set_fact: ansible_connection='ssh_lxc' | |||
- setup: | |||
- import_role: name='ssh_server' | |||
- set_fact: ansible_connection='ssh' | |||
- import_playbook: 'prepare_lxc_guest.yaml' | |||
vars: | |||
host: 'cloud' | |||
vm_size: '4G' | |||
- hosts: 'cloud' | |||
roles: | |||
- role: 'dns_record' | |||
- role: 'reverse_proxy' | |||
- role: 'nextcloud' | |||
- role: 'monitoring-agent' | |||
- hosts: 'status' | |||
- hosts: 'monitoring_hosts' | |||
roles: | |||
- role: 'icinga2-monitoring' | |||
... |
@ -0,0 +1,26 @@ | |||
--- | |||
- hosts: '{{ host }}' | |||
# Skip gather facts - host may not exist yet | |||
gather_facts: false | |||
tasks: | |||
- name: 'import lxc_guest role on lxc_host' | |||
import_role: name='lxc_guest' | |||
vars: | |||
vm_name: '{{ inventory_hostname }}' | |||
vm_size: '{{ vm_size }}' | |||
delegate_to: '{{ ansible_lxc_host }}' | |||
- name: 'enable ssh->lxc_attach connection' | |||
set_fact: ansible_connection='ssh_lxc' | |||
- name: 'gather facts - now the host must exist' | |||
setup: | |||
tags: | |||
- 'always' | |||
- name: 'configure ssh server' | |||
import_role: name='ssh_server' | |||
- name: 'enable ssh direct connection - ssh is configured on host' | |||
set_fact: ansible_connection='ssh' | |||
... |
@ -1,16 +1,17 @@ | |||
- hosts: biff | |||
--- | |||
- import_playbook: 'prepare_lxc_guest.yaml' | |||
vars: | |||
host: 'status' | |||
vm_size: '2G' | |||
- hosts: 'status' | |||
roles: | |||
- role: lxc_guest | |||
vm_name: status | |||
distro: stretch | |||
- role: ssh_server | |||
ansible_connection: ssh_lxc | |||
ansible_ssh_lxc_name: status | |||
- hosts: status | |||
- role: 'dns_record' | |||
- role: 'reverse_proxy' | |||
- role: 'icinga2' | |||
- hosts: 'status' | |||
roles: | |||
- role: dns_record | |||
- role: icinga2 | |||
- role: reverse_proxy | |||
- hosts: status | |||
roles: | |||
- role: icinga2-monitoring | |||
- role: 'icinga2-monitoring' | |||
... |