Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 117f388db7 | |||
| bdb66c69a6 |
49
Readme.md
49
Readme.md
@@ -1,46 +1,13 @@
|
||||
# ansible API
|
||||
|
||||
## Objectif
|
||||
|
||||
Utiliser ansible pour créer un container sur le cloud scaleway
|
||||
|
||||
## Documentation
|
||||
|
||||
https://docs.ansible.com/ansible/2.9/modules/scaleway_compute_module.html#scaleway-compute-module
|
||||
|
||||
## Informations utiles
|
||||
|
||||
* Id du projet: 8cf65c8f-64c0-47d3-9f50-fbe249b76aae
|
||||
* Id de l'image ( Alma Linux 9 ) : 26e4c50e-91d6-41a5-8898-9e40920e819d
|
||||
* Type commercial: DEV1-S
|
||||
* Zone: par1
|
||||
|
||||
clé secrète: **CHANGEME**
|
||||
|
||||
```yaml
|
||||
access_key: SCWP03YRZY6G8WTRHY9Z
|
||||
scw_api_secret_key: dc743230-9c09-43bc-bcca-7027a6d609e6
|
||||
default_organization_id: 6357800e-8b77-47a3-af7a-84ee93f019c2
|
||||
scw_api_default_project_id: 8cf65c8f-64c0-47d3-9f50-fbe249b76aae
|
||||
```
|
||||
|
||||
## Instructions:
|
||||
|
||||
Écrire un rôle permettant de créer un container sur le cloud scaleway, en utilisant les informations ci-dessus.
|
||||
|
||||
Le rôle doit permettre de spécifier le nom du container que l'on souhaite créer
|
||||
|
||||
Les données sensibles doivent être stockées dans un vault.
|
||||
|
||||
Une fois créé, le container doit être lancé.
|
||||
|
||||
Le rôle doit ensuite générer un fichier contenant:
|
||||
* le nom du container
|
||||
* son adresse ip
|
||||
|
||||
Ex:
|
||||
|
||||
```text
|
||||
- { record_name: mzaldjmaz00, record_value: 51.158.125.92 }
|
||||
- { record_name: mzaldjmaz01, record_value: 51.158.118.75 }
|
||||
---
|
||||
- hosts: localhost
|
||||
vars:
|
||||
scw_api_secret_key: CHANGEME
|
||||
scw_api_default_project_id: 8cf65c8f-64c0-47d3-9f50-fbe249b76aae
|
||||
container_name: evivbulgroz
|
||||
roles:
|
||||
- sib.scw_container
|
||||
```
|
||||
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
|
||||
54
sib.scw_container/README.md
Normal file
54
sib.scw_container/README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
Role Name
|
||||
=========
|
||||
|
||||
Create or delete container on scaleaway cloud
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
None
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
secret_key:
|
||||
default_project_id:
|
||||
|
||||
scw_type: DEV1-S
|
||||
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
|
||||
------------
|
||||
|
||||
None
|
||||
|
||||
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
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
7
sib.scw_container/defaults/main.yml
Normal file
7
sib.scw_container/defaults/main.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# defaults file for tco.scw_container
|
||||
scw_gen_hostlist: true
|
||||
scw_type: DEV1-S
|
||||
container_domain: formation.opendoor.fr
|
||||
container_image: 26e4c50e-91d6-41a5-8898-9e40920e819d
|
||||
container_number_start: 1
|
||||
2
sib.scw_container/handlers/main.yml
Normal file
2
sib.scw_container/handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for tco.scw_container
|
||||
52
sib.scw_container/meta/main.yml
Normal file
52
sib.scw_container/meta/main.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
# platforms:
|
||||
# - name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
13
sib.scw_container/tasks/main.yml
Normal file
13
sib.scw_container/tasks/main.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
|
||||
- name: "{{ container_prefix }} : Add"
|
||||
community.general.scaleway_compute:
|
||||
commercial_type: "{{ scw_type }}"
|
||||
region: par1
|
||||
name: "{{ container_name }}"
|
||||
state: "running"
|
||||
api_token: "{{ secret_key }}"
|
||||
image: "{{ container_image}}"
|
||||
project: "{{ default_project_id }}"
|
||||
public_ip: dynamic
|
||||
wait: true
|
||||
2
sib.scw_container/tests/inventory
Normal file
2
sib.scw_container/tests/inventory
Normal file
@@ -0,0 +1,2 @@
|
||||
localhost
|
||||
|
||||
9
sib.scw_container/tests/test.yml
Normal file
9
sib.scw_container/tests/test.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
vars:
|
||||
container_action: running
|
||||
container_number: 4
|
||||
container_prefix: plop
|
||||
container_image: lezknfe2324
|
||||
roles:
|
||||
- tco.scw_container
|
||||
2
sib.scw_container/vars/main.yml
Normal file
2
sib.scw_container/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for tco.scw_container
|
||||
Reference in New Issue
Block a user