--- ##################################################################### # # Playbook to deploy an LXD container as a new network host # # lxd-deploy.yml # # ansible-playbook -l -i lxdhost_inventory.yml lxd-deploy.yml # # This playbook will first deploy a new LXD container. It will then use # the lxd connection plugin to first do an initial network configuration # on the container, and will then make sure openssh-server is installed # and that the root user has a set of management ssh keys in its # 'authorized_keys' file. # # After deployment the setup-host.yml playbook can be used to configure the guest # as required. # ##################################################################### ##################################################################### # Start off with local connection to perform the initial container # deployment. After that it will use a mix of local and lxd # connections to prepare the container for management via ssh. - hosts: all connection: local user: root vars: guest_name: "{{ hostvars[inventory_hostname].inventory_hostname }}" guest_ip: "{{ hostvars[inventory_hostname].ansible_host }}" image_name: "{{ hostvars[inventory_hostname].image_name }}" image_vers: "{{ hostvars[inventory_hostname].image_vers }}" image_location: "{{ hostvars[inventory_hostname].image_location }}" deploy_host: "{{ hostvars[inventory_hostname].deploy_host }}" remote_name: "{{ hostvars[inventory_hostname].remote_name }}" guest_distro: "{{ hostvars[inventory_hostname].image_name }}" cpu_num: "{{ hostvars[inventory_hostname].cpu }}" mem_size: "{{ hostvars[inventory_hostname].mem }}" root_size: "{{ hostvars[inventory_hostname].root }}" host_type: "{{ hostvars[inventory_hostname].host_type }}" pre_tasks: - debug: msg="lxd-deploy.yml playbook" #################################################################### # use a role here rather than just the playbook as it is easier to # substitute templated files into the guest from within a role. roles: - role: lxd-deploy # EOF