|
|
|
|
@@ -1,15 +1,16 @@
|
|
|
|
|
---
|
|
|
|
|
- community.general.scaleway_compute:
|
|
|
|
|
commercial_type: "{{ item.host_type|default( scw_type )}}"
|
|
|
|
|
|
|
|
|
|
- name: "{{ container_prefix }} : {{ container_action }}"
|
|
|
|
|
community.general.scaleway_compute:
|
|
|
|
|
commercial_type: "{{ scw_type|default( scw_type )}}"
|
|
|
|
|
region: par1
|
|
|
|
|
name: "{{ container_prefix+'%02x' | format(item) }}"
|
|
|
|
|
name: "{{ container_name }}"
|
|
|
|
|
state: "{{ (container_action == 'delete' ) | ternary( 'absent', 'running' ) }}"
|
|
|
|
|
api_token: "{{ scw_api_secret_key }}"
|
|
|
|
|
image: "{{ container_image}}"
|
|
|
|
|
project: "{{ scw_api_default_project_id }}"
|
|
|
|
|
public_ip: dynamic
|
|
|
|
|
wait: true
|
|
|
|
|
loop: "{{ range(0, container_number , 1)|list }}"
|
|
|
|
|
register: "container_info"
|
|
|
|
|
|
|
|
|
|
- name: "generate host list"
|
|
|
|
|
@@ -23,8 +24,15 @@
|
|
|
|
|
- ansible.builtin.lineinfile:
|
|
|
|
|
create: yes
|
|
|
|
|
path: "hostlist.yml"
|
|
|
|
|
line: " - { record_name: {{ item.msg.name}}, record_type: A, record_value: {{ item.msg.public_ip.address }} }"
|
|
|
|
|
line: " - { record_name: {{ container_info.msg.name}}, record_type: A, record_value: {{ container_info.msg.public_ip.address }}, public_ip_id: {{ container_info.msg.public_ip.id }} }"
|
|
|
|
|
state: present
|
|
|
|
|
loop: "{{ container_info.results }}"
|
|
|
|
|
when: scw_gen_hostlist is true and container_action !='delete'
|
|
|
|
|
when: scw_gen_hostlist == 'true' and container_action !='delete'
|
|
|
|
|
|
|
|
|
|
- name: "delete ip "
|
|
|
|
|
community.general.scaleway_ip:
|
|
|
|
|
id: container_info.msg.public_ip.id
|
|
|
|
|
state: absent
|
|
|
|
|
api_token: "{{ scw_api_secret_key }}"
|
|
|
|
|
region: par1
|
|
|
|
|
organization: 6357800e-8b77-47a3-af7a-84ee93f019c2
|
|
|
|
|
when: container_action=='delete'
|
|
|
|
|
|