40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
---
|
|
- name: get container info
|
|
command:
|
|
cmd: "/usr/bin/incus config show {{ inventory_hostname }}"
|
|
register: container_info
|
|
ignore_errors: true
|
|
connection: local
|
|
delegate_to: localhost
|
|
|
|
- name: create container
|
|
command:
|
|
cmd: "/usr/bin/incus create images:{{ container_image }} {{ inventory_hostname }}"
|
|
when: '"Instance not found" in container_info.stderr'
|
|
connection: local
|
|
delegate_to: localhost
|
|
|
|
- name: configure ip
|
|
command:
|
|
cmd: "/usr/bin/incus config device add {{ inventory_hostname }} eth0 nic nictype=bridged parent=lxd ipv4.address={{ ansible_host }}"
|
|
when: '"Instance not found" in container_info.stderr'
|
|
connection: local
|
|
delegate_to: localhost
|
|
|
|
- name: start container
|
|
command:
|
|
cmd: "/usr/bin/incus start {{ inventory_hostname }}"
|
|
when: '"Instance not found" in container_info.stderr'
|
|
connection: local
|
|
delegate_to: localhost
|
|
|
|
- name: deploy motd
|
|
copy:
|
|
src: motd
|
|
dest: "/var/lib/incus/storage-pools/default/containers/{{ inventory_hostname }}/rootfs/etc/motd"
|
|
mode: 0644
|
|
owner: root
|
|
group: root
|
|
connection: local
|
|
delegate_to: localhost
|