metalsmith/roles/metalsmith_deployment/tasks/main.yml

41 lines
1.5 KiB
YAML

---
- name: Provision instances
command: >
metalsmith {{ extra_args }} deploy
{% for cap_name, cap_value in capabilities.items() %}
--capability {{ cap_name }}={{ cap_value }}
{% endfor %}
{% for nic in nics %}
{% for nic_type, nic_value in nic.items() %}
--{{ nic_type }} {{ nic_value }}
{% endfor %}
{% endfor %}
{% if root_size %}
--root-disk-size {{ root_size }}
{% endif %}
{% for ssh_key in ssh_public_keys %}
--ssh-public-key {{ ssh_key }}
{% endfor %}
--image {{ image }}
--hostname {{ instance.hostname }}
{% if netboot %}
--netboot
{% endif %}
{{ resource_class }}
when: state == 'present'
vars:
extra_args: "{{ instance.extra_args | default(metalsmith_extra_args) }}"
image: "{{ instance.image | default(metalsmith_image) }}"
capabilities: "{{ instance.capabilities | default(metalsmith_capabilities) }}"
netboot: "{{ instance.netboot | default(metalsmith_netboot) }}"
nics: "{{ instance.nics | default(metalsmith_nics) }}"
resource_class: "{{ instance.resource_class | default(metalsmith_resource_class) }}"
root_size: "{{ instance.root_size | default(metalsmith_root_size) }}"
ssh_public_keys: "{{ instance.ssh_public_keys | default(metalsmith_ssh_public_keys) }}"
state: "{{ instance.state | default('present') }}"
with_items: "{{ metalsmith_instances }}"
loop_control:
label: "{{ instance.hostname or instance }}"
loop_var: instance