First commit
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
vault_password.txt
|
||||||
@@ -1,2 +1,69 @@
|
|||||||
# ansible_update_vm_os_proxmox
|
# ansible_update_vm_os_proxmox
|
||||||
|
|
||||||
|
** Ne pas utiliser en production sur un ordinateur personnel. Dédier une VM à Ansible sur un hyperviseur sécurisé.**
|
||||||
|
|
||||||
|
Les fichiers de configurations inventory.yml, host_vars/* group_vars/* sont adapter pour VM, vous pouvez en ajouter ou en supprimer
|
||||||
|
|
||||||
|
# Valeurs à replacer et à adapter
|
||||||
|
|
||||||
|
Dans inventory.yml remplacer :
|
||||||
|
|
||||||
|
- ChangeMe-NameVm par le nom de votre vm. (à remplacer également dans les accolades {{ }})
|
||||||
|
|
||||||
|
Dans le dossier host_vars :
|
||||||
|
- Renommé ChangeMe-NameVm par le nom de votre vm.
|
||||||
|
|
||||||
|
À l'intérieur des fichier host_vars:
|
||||||
|
- Remplacer "Changeme-ID"par l'id de votre VM
|
||||||
|
- remplaer la valeur ChangeMe-NameVm dans {{ vault_ChangeMe-NameVm_root_password }}
|
||||||
|
|
||||||
|
Dans group_vars/vm/proxmox.yml:
|
||||||
|
- Remplacer ChangeMe-IpOrDnsName
|
||||||
|
- Adapter ansible@pam par un utilisateur ayant les droits de faire des snapshot et l'audit de vm
|
||||||
|
- Adapter ansible_snapshot par l'ID de votre token.
|
||||||
|
|
||||||
|
Dans le fichier group_vars/vm/vault.yml:
|
||||||
|
- Remplacer ChangeMe-NameVm par le nom de votre vm.
|
||||||
|
- Replacer ChangeMe-user par le nom d'utilisateur utilisé pour le ssh.
|
||||||
|
- Replacer ChangeMe-password par le mot de passe de l'utilisateur ssh.
|
||||||
|
- Remplacer ChangeMe-token_secret par le secret du token généré pour l'utilisateur Proxmox
|
||||||
|
- Remplacer ChangeMe-password_root par le mot de passe root de votre VM.
|
||||||
|
|
||||||
|
Dans le fichier group_vars/vm/variables.yml:
|
||||||
|
- Remplacer ChangeMe-NameVm0 dans la clé des variables ainsi que dans les accolades {{ vault_ChangeMe-NameVm_user }}
|
||||||
|
|
||||||
|
# Chiffrer le fichier vault.yml
|
||||||
|
|
||||||
|
Dabord, créer le fichier vault_password.txt à la racine du répertoire. Lui donner les droits avec chmod
|
||||||
|
|
||||||
|
```
|
||||||
|
chmod 600 vault_password.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Et renseigner le mot de passe pour ansible-vault.
|
||||||
|
|
||||||
|
Puis chiffrer le fichier vault.yml
|
||||||
|
|
||||||
|
```
|
||||||
|
ansible-vault encrypt group_vars/vm/vault.yml --encrypt-vault-id default
|
||||||
|
```
|
||||||
|
|
||||||
|
## Si vous ne voulez pas utiliser de fichier vault_password.txt
|
||||||
|
|
||||||
|
Retirer dans ansible.cfg :
|
||||||
|
|
||||||
|
vault_password_file = vault_password.txt
|
||||||
|
vault_identity_list = default@vault_password.txt
|
||||||
|
|
||||||
|
# Installer Ansible dans un venv
|
||||||
|
|
||||||
|
```
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
# Jouer votre playbook
|
||||||
|
|
||||||
|
```
|
||||||
|
ansible-playbook playbook.yml
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[defaults]
|
||||||
|
inventory = inventory.yml
|
||||||
|
vault_password_file = vault_password.txt
|
||||||
|
vault_identity_list = default@vault_password.txt
|
||||||
|
ask_pass = False
|
||||||
|
|
||||||
|
|
||||||
|
[ssh_connection]
|
||||||
|
ssh_args = -o PreferredAuthentications=password -o PubkeyAuthentication=no
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
proxmox_snapshot_api_host: "ChangeMe-IpOrDnsName"
|
||||||
|
proxmox_snapshot_api_user: "ansible@pam"
|
||||||
|
proxmox_snapshot_api_token_id: "ansible_snapshot"
|
||||||
|
proxmox_snapshot_api_token_secret: "{{ vault_proxmox_snapshot_api_token_secret }}"
|
||||||
|
proxmox_snapshot_node: "pve"
|
||||||
|
proxmox_snapshot_vmid: ""
|
||||||
|
proxmox_snapshot_validate_certs: false
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
ChangeMe-NameVm0_user: "{{ vault_ChangeMe-NameVm0_user }}"
|
||||||
|
ChangeMe-NameVm0_password: "{{ vault_ChangeMe-NameVm0_password }}"
|
||||||
|
ChangeMe-NameVm1_user: "{{ vault_ChangeMe-NameVm1_user }}"
|
||||||
|
ChangeMe-NameVm1_password: "{{ vault_ChangeMe-NameVm1_password }}"
|
||||||
|
ChangeMe-NameVm2_user: "{{ vault_ChangeMe-NameVm2_user }}"
|
||||||
|
ChangeMe-NameVm2_password: "{{ vault_ChangeMe-NameVm2_password }}"
|
||||||
|
ChangeMe-NameVm3_user: "{{ vault_ChangeMe-NameVm3_user }}"
|
||||||
|
ChangeMe-NameVm3_password: "{{ vault_ChangeMe-NameVm3_password }}"
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
vault_ChangeMe-NameVm0_user: ChangeMe-user
|
||||||
|
vault_ChangeMe-NameVm0_password: ChangeMe-password
|
||||||
|
vault_ChangeMe-NameVm1_user: ChangeMe-user
|
||||||
|
vault_ChangeMe-NameVm1_password: ChangeMe-password
|
||||||
|
vault_ChangeMe-NameVm2_user: ChangeMe-user
|
||||||
|
vault_ChangeMe-NameVm3_password: ChangeMe-password
|
||||||
|
vault_ChangeMe-NameVm3_user: ChangeMe-user
|
||||||
|
vault_ChangeMe-NameVm3_password: ChangeMe-password
|
||||||
|
vault_proxmox_snapshot_api_token_secret: "ChangeMe-token_secret"
|
||||||
|
vault_ChangeMe-NameVm0_root_password: "ChangeMe-password_root"
|
||||||
|
vault_ChangeMe-NameVm1_root_password: "ChangeMe-password_root"
|
||||||
|
vault_ChangeMe-NameVm2_root_password: "ChangeMe-password_root"
|
||||||
|
vault_ChangeMe-NameVm3_root_password: "ChangeMe-password_root"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
proxmox_snapshot_vmid: "ChangeMe-ID"
|
||||||
|
health_urls:
|
||||||
|
- https://url.domaine/HealtzPath
|
||||||
|
ansible_become_user: "root"
|
||||||
|
ansible_become_password: "{{ vault_ChangeMe-NameVm0_root_password }}"
|
||||||
|
ansible_become_method: su
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
proxmox_snapshot_vmid: "ChangeMe-ID"
|
||||||
|
health_urls:
|
||||||
|
- https://url.domaine/HealtzPath
|
||||||
|
ansible_become_user: "root"
|
||||||
|
ansible_become_password: "{{ vault_ChangeMe-NameVm0_root_password }}"
|
||||||
|
ansible_become_method: su
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
proxmox_snapshot_vmid: "ChangeMe-ID"
|
||||||
|
health_urls:
|
||||||
|
- https://url.domaine/HealtzPath
|
||||||
|
ansible_become_user: "root"
|
||||||
|
ansible_become_password: "{{ vault_ChangeMe-NameVm0_root_password }}"
|
||||||
|
ansible_become_method: su
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
proxmox_snapshot_vmid: "ChangeMe-ID"
|
||||||
|
health_urls:
|
||||||
|
- https://url.domaine/HealtzPath
|
||||||
|
ansible_become_user: "root"
|
||||||
|
ansible_become_password: "{{ vault_ChangeMe-NameVm0_root_password }}"
|
||||||
|
ansible_become_method: su
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
all:
|
||||||
|
children:
|
||||||
|
vm:
|
||||||
|
hosts:
|
||||||
|
NameVm0:
|
||||||
|
ansible_host: ip_or_dns_name
|
||||||
|
ansible_user: "{{ vault_NameVm0_user }}"
|
||||||
|
ansible_password: "{{ vault_docker_password }}"
|
||||||
|
NameVm1:
|
||||||
|
ansible_host: ip_or_dns_name
|
||||||
|
ansible_user: "{{ vault_NameVm1_user }}"
|
||||||
|
ansible_password: "{{ vault_gitea_password }}"
|
||||||
|
NameVm2:
|
||||||
|
ansible_host: ip_or_dns_name
|
||||||
|
ansible_user: "{{ vault_NameVm2_user }}"
|
||||||
|
ansible_password: "{{ vault_drone_password }}"
|
||||||
|
NameVm3:
|
||||||
|
ansible_host: ip_or_dns_name
|
||||||
|
ansible_user: "{{ vault_NameVm3_user }}"
|
||||||
|
ansible_password: "{{ vault_dokku_password }}"
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
- hosts: vm
|
||||||
|
serial: 1
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- check_healtz
|
||||||
|
- proxmox_snapshot
|
||||||
|
- role: update_os
|
||||||
|
become: true
|
||||||
|
- check_healtz
|
||||||
|
- proxmox_snapshot_remove
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
ansible==14.2.0
|
||||||
|
ansible-core==2.21.2
|
||||||
|
certifi==2026.7.22
|
||||||
|
cffi==2.1.0
|
||||||
|
charset-normalizer==3.4.9
|
||||||
|
cryptography==49.0.0
|
||||||
|
idna==3.18
|
||||||
|
Jinja2==3.1.6
|
||||||
|
MarkupSafe==3.0.3
|
||||||
|
packaging==26.2
|
||||||
|
proxmoxer==2.3.0
|
||||||
|
pycparser==3.0
|
||||||
|
PyYAML==6.0.3
|
||||||
|
requests==2.34.2
|
||||||
|
resolvelib==1.2.1
|
||||||
|
urllib3==2.7.0
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
A brief description of the role goes here.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||||
|
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- { role: username.rolename, x: 42 }
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# defaults file for roles/check_healtz
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# handlers file for roles/check_healtz
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
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.2
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
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.2
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
allow_duplicates: true
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# tasks file for roles/check_healtz
|
||||||
|
- name: Vérifier les services web
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ item }}"
|
||||||
|
method: GET
|
||||||
|
status_code: 200
|
||||||
|
validate_certs: true
|
||||||
|
register: health_check
|
||||||
|
retries: 12
|
||||||
|
delay: 10
|
||||||
|
until: health_check.status == 200
|
||||||
|
loop: "{{ health_urls | default([]) }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item }}"
|
||||||
|
delegate_to: localhost
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
localhost
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- roles/check_healtz
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# vars file for roles/check_healtz
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
A brief description of the role goes here.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||||
|
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- { role: username.rolename, x: 42 }
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
proxmox_snapshot_api_host: ""
|
||||||
|
proxmox_snapshot_api_user: ""
|
||||||
|
proxmox_snapshot_api_token_id: ""
|
||||||
|
proxmox_snapshot_api_token_secret: "" #Vault
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for roles/proxmox_snapshot
|
||||||
@@ -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.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
- name: Création d'un snapshot
|
||||||
|
community.proxmox.proxmox_snap:
|
||||||
|
api_host: "{{ proxmox_snapshot_api_host }}"
|
||||||
|
api_user: "{{ proxmox_snapshot_api_user }}"
|
||||||
|
api_token_id: "{{ proxmox_snapshot_api_token_id }}"
|
||||||
|
api_token_secret: "{{ proxmox_snapshot_api_token_secret }}"
|
||||||
|
vmid: "{{ proxmox_snapshot_vmid }}"
|
||||||
|
state: present
|
||||||
|
snapname: "ansible_sandbox_snapshot_update_os"
|
||||||
|
validate_certs: "{{ proxmox_snapshot_validate_certs }}"
|
||||||
|
delegate_to: localhost
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- roles/proxmox_snapshot
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for roles/proxmox_snapshot
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
A brief description of the role goes here.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||||
|
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- { role: username.rolename, x: 42 }
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# defaults file for roles/proxmox_snapshot_remove
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# handlers file for roles/proxmox_snapshot_remove
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
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.2
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
- name: Suppresion du snapshot
|
||||||
|
community.proxmox.proxmox_snap:
|
||||||
|
api_host: "{{ proxmox_snapshot_api_host }}"
|
||||||
|
api_user: "{{ proxmox_snapshot_api_user }}"
|
||||||
|
api_token_id: "{{ proxmox_snapshot_api_token_id }}"
|
||||||
|
api_token_secret: "{{ proxmox_snapshot_api_token_secret }}"
|
||||||
|
vmid: "{{ proxmox_snapshot_vmid }}"
|
||||||
|
state: absent
|
||||||
|
snapname: "ansible_sandbox_snapshot_update_os"
|
||||||
|
timeout: 300
|
||||||
|
validate_certs: "{{ proxmox_snapshot_validate_certs }}"
|
||||||
|
delegate_to: localhost
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
localhost
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- roles/proxmox_snapshot_remove
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#SPDX-License-Identifier: MIT-0
|
||||||
|
---
|
||||||
|
# vars file for roles/proxmox_snapshot_remove
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
A brief description of the role goes here.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||||
|
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- { role: username.rolename, x: 42 }
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for roles/update_os
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for roles/update_os
|
||||||
@@ -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.
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
- name: Mise à jour du cache APT
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
|
- name: Mise à jour complète
|
||||||
|
ansible.builtin.apt:
|
||||||
|
upgrade: dist
|
||||||
|
autoremove: true
|
||||||
|
autoclean: true
|
||||||
|
|
||||||
|
- name: Vérifier si un reboot est nécessaire
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /var/run/reboot-required
|
||||||
|
register: reboot_required
|
||||||
|
|
||||||
|
- name: Redémarrer la machine
|
||||||
|
ansible.builtin.reboot:
|
||||||
|
reboot_timeout: 900
|
||||||
|
post_reboot_delay: 20
|
||||||
|
when: reboot_required.stat.exists
|
||||||
|
|
||||||
|
- name: Attendre SSH
|
||||||
|
ansible.builtin.wait_for_connection:
|
||||||
|
timeout: 300
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- roles/update_os
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for roles/update_os
|
||||||
Reference in New Issue
Block a user