solution de base, sans génération du fichier

This commit is contained in:
2024-06-19 17:56:11 +02:00
parent bdb66c69a6
commit 117f388db7
8 changed files with 38 additions and 54 deletions

10
add_container.yml Normal file
View 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

View File

@@ -1,7 +1,7 @@
Role Name
=========
Create container on scaleaway cloud
Create or delete container on scaleaway cloud
Requirements
------------
@@ -11,12 +11,15 @@ None
Role Variables
--------------
container_name:
scw_api_secret_key:
scw_api_default_project_id:
secret_key:
default_project_id:
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
------------
@@ -29,10 +32,16 @@ Example Playbook
```yaml
---
- hosts: localhost
vars:
container_action: running
container_name: plope
container_image: lezknfe2324
roles:
- tco.scw_container
```
will create containers plope.formation.opendoor.fr
License
-------

View File

@@ -1,5 +1,7 @@
---
# defaults file for tco.scw_container
scw_gen_hostlist: true
scw_type: DEV1-S
scw_image: 26e4c50e-91d6-41a5-8898-9e40920e819d
scw_region: par1
container_domain: formation.opendoor.fr
container_image: 26e4c50e-91d6-41a5-8898-9e40920e819d
container_number_start: 1

View File

@@ -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 }}'

View File

@@ -1,22 +1,13 @@
---
- name: create container
- name: "{{ container_prefix }} : Add"
community.general.scaleway_compute:
commercial_type: "{{ scw_type }}"
region: par1
name: "{{ container_name }}"
state: running
api_token: "{{ scw_api_secret_key }}"
image: "{{ scw_image}}"
project: "{{ scw_api_default_project_id }}"
state: "running"
api_token: "{{ secret_key }}"
image: "{{ container_image}}"
project: "{{ default_project_id }}"
public_ip: dynamic
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 }}"

View File

@@ -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 }

View File

@@ -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 }}"

View File

@@ -1,12 +1,9 @@
# call me with --extra-vars=@hostlist.yml
---
- hosts: localhost
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_number: 4
container_prefix: plop
container_image: lezknfe2324
roles:
- tco.scw_container
- { role: tco.dns, dns_action: "add" }