solution de base, sans génération du fichier
This commit is contained in:
10
add_container.yml
Normal file
10
add_container.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
vars:
|
||||||
|
access_key: SCWR6N2K4C6HYH89H5GR
|
||||||
|
secret_key: 33c114f3-b49a-4bcc-8ef0-38eb84f10612
|
||||||
|
default_organization_id: 6357800e-8b77-47a3-af7a-84ee93f019c2
|
||||||
|
default_project_id: 8cf65c8f-64c0-47d3-9f50-fbe249b76aae
|
||||||
|
container_image: 26e4c50e-91d6-41a5-8898-9e40920e819d
|
||||||
|
roles:
|
||||||
|
- sib.scw_container
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
Role Name
|
Role Name
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Create container on scaleaway cloud
|
Create or delete container on scaleaway cloud
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
@@ -11,12 +11,15 @@ None
|
|||||||
Role Variables
|
Role Variables
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
container_name:
|
secret_key:
|
||||||
scw_api_secret_key:
|
default_project_id:
|
||||||
scw_api_default_project_id:
|
|
||||||
|
|
||||||
scw_type: DEV1-S
|
scw_type: DEV1-S
|
||||||
scw_image: 26e4c50e-91d6-41a5-8898-9e40920e819d
|
container_action; delete or running
|
||||||
|
container_name:
|
||||||
|
container_domain: default formation.opendoor.fr
|
||||||
|
scw_gen_hostlist: default true, wether we create a hostlist.yml file containing containers name and ip (to be fed to dns role to create records)
|
||||||
|
container_image: id of image default alma9 26e4c50e-91d6-41a5-8898-9e40920e819d
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
@@ -29,10 +32,16 @@ Example Playbook
|
|||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
|
vars:
|
||||||
|
container_action: running
|
||||||
|
container_name: plope
|
||||||
|
container_image: lezknfe2324
|
||||||
roles:
|
roles:
|
||||||
- tco.scw_container
|
- tco.scw_container
|
||||||
```
|
```
|
||||||
|
|
||||||
|
will create containers plope.formation.opendoor.fr
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
# defaults file for tco.scw_container
|
# defaults file for tco.scw_container
|
||||||
|
scw_gen_hostlist: true
|
||||||
scw_type: DEV1-S
|
scw_type: DEV1-S
|
||||||
scw_image: 26e4c50e-91d6-41a5-8898-9e40920e819d
|
container_domain: formation.opendoor.fr
|
||||||
scw_region: par1
|
container_image: 26e4c50e-91d6-41a5-8898-9e40920e819d
|
||||||
|
container_number_start: 1
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
# remove opendoor.fr[.] d'un ndm si besoin
|
|
||||||
#
|
|
||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
vars:
|
|
||||||
zone: "opendoor.fr"
|
|
||||||
tasks:
|
|
||||||
- debug:
|
|
||||||
msg: "{{ item.record_name | ansible.builtin.regex_replace( '.'+zone, '' ) }}"
|
|
||||||
#msg: "{{ item.record_name | ansible.builtin.regex_replace( '.'+zone+'.?', '' ) }}"
|
|
||||||
loop: '{{ dns_records }}'
|
|
||||||
@@ -1,22 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: create container
|
|
||||||
|
- name: "{{ container_prefix }} : Add"
|
||||||
community.general.scaleway_compute:
|
community.general.scaleway_compute:
|
||||||
commercial_type: "{{ scw_type }}"
|
commercial_type: "{{ scw_type }}"
|
||||||
|
region: par1
|
||||||
name: "{{ container_name }}"
|
name: "{{ container_name }}"
|
||||||
state: running
|
state: "running"
|
||||||
api_token: "{{ scw_api_secret_key }}"
|
api_token: "{{ secret_key }}"
|
||||||
image: "{{ scw_image}}"
|
image: "{{ container_image}}"
|
||||||
project: "{{ scw_api_default_project_id }}"
|
project: "{{ default_project_id }}"
|
||||||
public_ip: dynamic
|
public_ip: dynamic
|
||||||
wait: true
|
wait: true
|
||||||
region: "{{ scw_region }}"
|
|
||||||
register: "container_info"
|
|
||||||
|
|
||||||
- name: "generate host list"
|
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
create: yes
|
|
||||||
path: "hostlist.yml"
|
|
||||||
line: " - { record_name: {{ item.msg.name}}, record_value: {{ item.msg.public_ip.address }} }"
|
|
||||||
state: present
|
|
||||||
loop: "{{ container_info.results }}"
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
dns_records:
|
|
||||||
- { record_name: test3.formation.opendoor.fr., record_type: A, record_value: 51.15.243.244 }
|
|
||||||
- { record_name: test4.formation.opendoor.fr., record_type: A, record_value: 212.47.251.35 }
|
|
||||||
- { record_name: test5.formation.opendoor.fr., record_type: A, record_value: 51.15.142.152 }
|
|
||||||
- { record_name: test3.formation.opendoor.fr, record_type: A, record_value: 51.15.243.244 }
|
|
||||||
- { record_name: test4.formation.opendoor.fr, record_type: A, record_value: 212.47.251.35 }
|
|
||||||
- { record_name: test5.formation.opendoor.fr, record_type: A, record_value: 51.15.142.152 }
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
tasks:
|
|
||||||
- name: with_sequence -> loop
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: "{{ 'testuser%02x' | format(item) }}"
|
|
||||||
loop: "{{ range(0, 4 + 1, 2)|list }}"
|
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
# call me with --extra-vars=@hostlist.yml
|
|
||||||
---
|
---
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
vars:
|
vars:
|
||||||
container_list:
|
|
||||||
- { host_name: test3.formation.opendoor.fr, host_type: DEV1-S, host_image: 26e4c50e-91d6-41a5-8898-9e40920e819d }
|
|
||||||
- { host_name: test4.formation.opendoor.fr, host_type: DEV1-S, host_image: 26e4c50e-91d6-41a5-8898-9e40920e819d }
|
|
||||||
- { host_name: test5.formation.opendoor.fr, host_type: DEV1-S, host_image: 26e4c50e-91d6-41a5-8898-9e40920e819d }
|
|
||||||
container_action: running
|
container_action: running
|
||||||
|
container_number: 4
|
||||||
|
container_prefix: plop
|
||||||
|
container_image: lezknfe2324
|
||||||
roles:
|
roles:
|
||||||
- tco.scw_container
|
- tco.scw_container
|
||||||
- { role: tco.dns, dns_action: "add" }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user