--- - include: bootstrap-other.yml when: > inventory_hostname not in lxd_status - name: "Set interface MAC addresses" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" shell: >- lxc config set {{ hostvars[inventory_hostname].lxd_host | quote }}:{{ inventory_hostname | quote }} volatile.{{ item.interface | quote }}.hwaddr {{ item.mac_address | quote}} with_items: "{{ hostvars[inventory_hostname].network.values() | list }}" when: '"mac_address" in item' - name: "Set LXD custom configuration parameters" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" shell: >- lxc config set {{ hostvars[inventory_hostname].lxd_host | quote }}:{{ inventory_hostname | quote }} {{ item.name | quote }} {{ item.value | quote }} with_items: - name: boot.autostart.priority value: "{{ hostvars[inventory_hostname].lxd_boot_priority | default(0) }}" - name: "Stop created LXD container" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" lxd_container: name: "{{ inventory_hostname }}" state: stopped when: inventory_hostname not in lxd_status - name: "Start created LXD container" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" lxd_container: name: "{{ inventory_hostname }}" state: started wait_for_ipv4_addresses: True when: inventory_hostname not in lxd_status - name: "Update packages on created LXD container" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" shell: lxc exec {{ inventory_hostname }} -- apt-get update when: inventory_hostname not in lxd_status - name: "Upgrade packages on created LXD container" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" shell: lxc exec {{ inventory_hostname }} -- apt-get upgrade -y when: inventory_hostname not in lxd_status - name: "Autoremove packages on created LXD container" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" shell: lxc exec {{ inventory_hostname }} -- apt-get autoremove -y when: inventory_hostname not in lxd_status - name: "Autoclean packages on created LXD container" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" shell: lxc exec {{ inventory_hostname }} -- apt-get autoclean -y when: inventory_hostname not in lxd_status - name: "Disable hostname management from cloud-init" delegate_to: "{{ hostvars[inventory_hostname].lxd_host }}" shell: >- lxc exec {{ inventory_hostname }} -- sed -i -e 's/^\\s*preserve_hostname\\s*:.*/preserve_hostname: true/' /etc/cloud/cloud.cfg tags: [ hostname ] when: hostvars[inventory_hostname].distribution_codename != "trusty"