Compare commits
7 Commits
efb3265a4e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7249205715 | |||
| 4ac888ef7f | |||
| d1dbc79371 | |||
| dfef258dd5 | |||
| 206b9f7659 | |||
| 43abe12bbd | |||
| bec5624f75 |
@@ -1,3 +1,6 @@
|
|||||||
---
|
---
|
||||||
# defaults file for tco.scw_container
|
# defaults file for tco.scw_container
|
||||||
scw_gen_hostlist: true
|
scw_gen_hostlist: 'true'
|
||||||
|
scw_type: DEV1-S
|
||||||
|
container_image: 024676ab-6b3c-4473-b538-181a688d62e7
|
||||||
|
container_number_start: 1
|
||||||
|
|||||||
@@ -1,22 +1,38 @@
|
|||||||
---
|
---
|
||||||
- community.general.scaleway_compute:
|
|
||||||
commercial_type: DEV1-S
|
- name: "{{ container_prefix }} : {{ container_action }}"
|
||||||
|
community.general.scaleway_compute:
|
||||||
|
commercial_type: "{{ scw_type|default( scw_type )}}"
|
||||||
region: par1
|
region: par1
|
||||||
name: "{{ item}}"
|
name: "{{ container_name }}"
|
||||||
state: "{{ (container_action == 'delete' ) | ternary( 'absent', 'running' ) }}"
|
state: "{{ (container_action == 'delete' ) | ternary( 'absent', 'running' ) }}"
|
||||||
api_token: "{{ scw_api_secret_key }}"
|
api_token: "{{ scw_api_secret_key }}"
|
||||||
image: 26e4c50e-91d6-41a5-8898-9e40920e819d
|
image: "{{ container_image}}"
|
||||||
project: "{{ scw_api_default_project_id }}"
|
project: "{{ scw_api_default_project_id }}"
|
||||||
public_ip: dynamic
|
public_ip: dynamic
|
||||||
loop: "{{ container_list }}"
|
wait: true
|
||||||
register: "container_info"
|
register: "container_info"
|
||||||
|
|
||||||
- name: "generate host list"
|
- name: "generate host list"
|
||||||
ansible.builtin.lineinfile:
|
block:
|
||||||
create: yes
|
- ansible.builtin.lineinfile:
|
||||||
path: "hostlist.yml"
|
create: yes
|
||||||
line: "- { record_name: {{ item.msg.name}}, record_type: A, record_value: {{ item.msg.public_ip.address }} "
|
path: "hostlist.yml"
|
||||||
state: present
|
line: "dns_records:"
|
||||||
loop: "{{ container_info.results }}"
|
insertbefore: BOF
|
||||||
when: scw_gen_hostlist is true and container_action !='delete'
|
|
||||||
|
|
||||||
|
- ansible.builtin.lineinfile:
|
||||||
|
create: yes
|
||||||
|
path: "hostlist.yml"
|
||||||
|
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
|
||||||
|
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'
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
remote_user: root
|
vars:
|
||||||
|
container_action: running
|
||||||
|
container_number: 4
|
||||||
|
container_prefix: plop
|
||||||
|
container_image: lezknfe2324
|
||||||
roles:
|
roles:
|
||||||
- tco.scw_container
|
- tco.scw_container
|
||||||
|
|||||||
Reference in New Issue
Block a user