initial project commit
This commit is contained in:
commit
2c9d85e94a
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Ansible Collection - jchristianh.pve
|
||||||
|
|
||||||
|
Documentation for the collection.
|
62
galaxy.yml
Normal file
62
galaxy.yml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
### REQUIRED
|
||||||
|
# The namespace of the collection. This can be a company/brand/organization or product namespace under which all
|
||||||
|
# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with
|
||||||
|
# underscores or numbers and cannot contain consecutive underscores
|
||||||
|
namespace: jchristianh
|
||||||
|
|
||||||
|
# The name of the collection. Has the same character restrictions as 'namespace'
|
||||||
|
name: pve
|
||||||
|
|
||||||
|
# The version of the collection. Must be compatible with semantic versioning
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
|
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
|
||||||
|
readme: README.md
|
||||||
|
|
||||||
|
# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
|
||||||
|
# @nicks:irc/im.site#channel'
|
||||||
|
authors:
|
||||||
|
- your name <example@domain.com>
|
||||||
|
|
||||||
|
|
||||||
|
### OPTIONAL but strongly recommended
|
||||||
|
# A short summary description of the collection
|
||||||
|
description: your collection description
|
||||||
|
|
||||||
|
# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
|
||||||
|
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
|
||||||
|
license:
|
||||||
|
- GPL-2.0-or-later
|
||||||
|
|
||||||
|
# The path to the license file for the collection. This path is relative to the root of the collection. This key is
|
||||||
|
# mutually exclusive with 'license'
|
||||||
|
license_file: ''
|
||||||
|
|
||||||
|
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
|
||||||
|
# requirements as 'namespace' and 'name'
|
||||||
|
tags: []
|
||||||
|
|
||||||
|
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
|
||||||
|
# collection label 'namespace.name'. The value is a version range
|
||||||
|
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
|
||||||
|
# range specifiers can be set and are separated by ','
|
||||||
|
dependencies: {}
|
||||||
|
|
||||||
|
# The URL of the originating SCM repository
|
||||||
|
repository: http://example.com/repository
|
||||||
|
|
||||||
|
# The URL to any online docs
|
||||||
|
documentation: http://docs.example.com
|
||||||
|
|
||||||
|
# The URL to the homepage of the collection/project
|
||||||
|
homepage: http://example.com
|
||||||
|
|
||||||
|
# The URL to the collection issue tracker
|
||||||
|
issues: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
# A list of file glob-like patterns used to filter any files or directories that should not be included in the build
|
||||||
|
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
|
||||||
|
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
|
||||||
|
# and '.git' are always filtered
|
||||||
|
build_ignore: []
|
||||||
|
|
31
plugins/README.md
Normal file
31
plugins/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Collections Plugins Directory
|
||||||
|
|
||||||
|
This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that
|
||||||
|
is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that
|
||||||
|
would contain module utils and modules respectively.
|
||||||
|
|
||||||
|
Here is an example directory of the majority of plugins currently supported by Ansible:
|
||||||
|
|
||||||
|
```
|
||||||
|
└── plugins
|
||||||
|
├── action
|
||||||
|
├── become
|
||||||
|
├── cache
|
||||||
|
├── callback
|
||||||
|
├── cliconf
|
||||||
|
├── connection
|
||||||
|
├── filter
|
||||||
|
├── httpapi
|
||||||
|
├── inventory
|
||||||
|
├── lookup
|
||||||
|
├── module_utils
|
||||||
|
├── modules
|
||||||
|
├── netconf
|
||||||
|
├── shell
|
||||||
|
├── strategy
|
||||||
|
├── terminal
|
||||||
|
├── test
|
||||||
|
└── vars
|
||||||
|
```
|
||||||
|
|
||||||
|
A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible-core/2.12/plugins/plugins.html).
|
38
roles/configure_vms/README.md
Normal file
38
roles/configure_vms/README.md
Normal file
@ -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).
|
2
roles/configure_vms/defaults/main.yml
Normal file
2
roles/configure_vms/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for configure_vms
|
2
roles/configure_vms/handlers/main.yml
Normal file
2
roles/configure_vms/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for configure_vms
|
52
roles/configure_vms/meta/main.yml
Normal file
52
roles/configure_vms/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.
|
71
roles/configure_vms/tasks/main.yml
Normal file
71
roles/configure_vms/tasks/main.yml
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
- name: Wait for VM creation...
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/\
|
||||||
|
{{ item.vmid }}/status/current"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_wait_for_vm
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
until : r_wait_for_vm.status == 200 and r_wait_for_vm.json.data.status is defined
|
||||||
|
retries : "{{ __api_retries }}"
|
||||||
|
delay : "{{ __api_polling }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Get current VM configuration
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/\
|
||||||
|
{{ item.vmid }}/config"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_get_vm_config
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
until : r_get_vm_config.status == 200 and r_get_vm_config.json.data.net0 is defined
|
||||||
|
retries : "{{ __api_retries }}"
|
||||||
|
delay : "{{ __api_polling }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Process configuration data
|
||||||
|
set_fact:
|
||||||
|
r_setup_config_data: "{{ lookup('template', 'vm_config_lookup.j2') }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Configure VMs
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/\
|
||||||
|
{{ item.vmid }}/config"
|
||||||
|
method : POST
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
body_format : form-urlencoded
|
||||||
|
body :
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
cores : "{{ item.cores | default(__lab_cores_default) }}"
|
||||||
|
memory : "{{ '{0:0.0f}'.format(item.mem|default(__lab_mem_default) * 1024)|int }}"
|
||||||
|
net0 : "virtio={{ item.mac_addr}},bridge={{ __lab_bridge }},tag={{ __lab_vlan }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_config_vm
|
||||||
|
loop : "{{ r_setup_config_data }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
when :
|
||||||
|
- item.status == 'stopped'|lower
|
||||||
|
|
||||||
|
|
||||||
|
...
|
17
roles/configure_vms/templates/vm_config_lookup.j2
Normal file
17
roles/configure_vms/templates/vm_config_lookup.j2
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{% for vm_wait in r_wait_for_vm.results %}
|
||||||
|
{% for vm_config in r_get_vm_config.results %}
|
||||||
|
{% if vm_wait.item.name == vm_config.item.name %}
|
||||||
|
{
|
||||||
|
"name" : "{{ vm_config.item.name }}",
|
||||||
|
"vmid" : "{{ vm_config.item.vmid }}",
|
||||||
|
"vm_host" : "{{ vm_config.item.vm_host }}",
|
||||||
|
"status" : "{{ vm_wait.json.data.status }}",
|
||||||
|
"cores" : "{{ vm_config.item.cores }}",
|
||||||
|
"mem" : {{ vm_config.item.mem }},
|
||||||
|
"mac_addr" : "{{ vm_config.json.data.net0 | regex_replace('^virtio=(.*),bridge=.*$','\\1') }}",
|
||||||
|
},
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
]
|
2
roles/configure_vms/tests/inventory
Normal file
2
roles/configure_vms/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/configure_vms/tests/test.yml
Normal file
5
roles/configure_vms/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- configure_vms
|
2
roles/configure_vms/vars/main.yml
Normal file
2
roles/configure_vms/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for configure_vms
|
38
roles/create_ansible_inventory/README.md
Normal file
38
roles/create_ansible_inventory/README.md
Normal file
@ -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).
|
2
roles/create_ansible_inventory/defaults/main.yml
Normal file
2
roles/create_ansible_inventory/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for create_ansible_inventory
|
2
roles/create_ansible_inventory/handlers/main.yml
Normal file
2
roles/create_ansible_inventory/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for create_ansible_inventory
|
52
roles/create_ansible_inventory/meta/main.yml
Normal file
52
roles/create_ansible_inventory/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.
|
26
roles/create_ansible_inventory/tasks/main.yml
Normal file
26
roles/create_ansible_inventory/tasks/main.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
- name: Create inventory for Environment
|
||||||
|
block:
|
||||||
|
- name: Write inventory
|
||||||
|
template :
|
||||||
|
src : "{{ lab_inv_tmpl }}"
|
||||||
|
dest : "{{ lab_inv_dest }}/{{ lab_inv_file }}"
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Pause for 10s
|
||||||
|
pause:
|
||||||
|
seconds: 10
|
||||||
|
|
||||||
|
|
||||||
|
- name: Fetch VM info
|
||||||
|
include_role:
|
||||||
|
name: jchristianh.pve.get_vm_ipaddr
|
||||||
|
|
||||||
|
|
||||||
|
- name: Write inventory
|
||||||
|
template :
|
||||||
|
src : "{{ lab_inv_tmpl }}"
|
||||||
|
dest : "{{ lab_inv_dest }}/{{ lab_inv_file }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
@ -0,0 +1,60 @@
|
|||||||
|
# {{ lab_template_header }} Inventory
|
||||||
|
#################################################
|
||||||
|
#
|
||||||
|
# Configuration : {{ lab_inv_file }}
|
||||||
|
# Template Version : {{ lab_inv_ver }}-{{ lab_inv_rev }}
|
||||||
|
#
|
||||||
|
# {{ __project_maintainer }} <{{ __project_maintainer_email }}>
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Environment Overview #
|
||||||
|
# -------------------- #
|
||||||
|
# KEY: #
|
||||||
|
# Node :: Group :: IP #
|
||||||
|
#########################
|
||||||
|
{% for node in r_hosts_inventory %}
|
||||||
|
# {{ node.name }} :: {{ node.group }} :: {{ node.address }} :: {{ node.vm_host }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
### HOST GROUPS ###
|
||||||
|
###################
|
||||||
|
{% for group in lab_groups %}
|
||||||
|
[{{ group }}]
|
||||||
|
{% for node in r_hosts_inventory %}
|
||||||
|
{% if node.group == group %}
|
||||||
|
{{ node.name }} ansible_host={{ node.address }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if lab_parents is defined %}
|
||||||
|
#################
|
||||||
|
### SUBGROUPS ###
|
||||||
|
#################
|
||||||
|
{% for parent in lab_parents %}
|
||||||
|
[{{ parent }}:children]
|
||||||
|
{% for group in lab_parents[parent].groups %}
|
||||||
|
{{ group }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
[{{ parent }}:vars]
|
||||||
|
{% for var in lab_parents[parent].vars %}
|
||||||
|
{{ var }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
# vars for all hosts/groups
|
||||||
|
[all:vars]
|
||||||
|
{% if __use_bastion is defined and __use_bastion|bool %}
|
||||||
|
ansible_ssh_common_args='-J {{ __bastion_user }}@{{ __bastion_host }}'
|
||||||
|
{% endif %}
|
2
roles/create_ansible_inventory/tests/inventory
Normal file
2
roles/create_ansible_inventory/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/create_ansible_inventory/tests/test.yml
Normal file
5
roles/create_ansible_inventory/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- create_ansible_inventory
|
2
roles/create_ansible_inventory/vars/main.yml
Normal file
2
roles/create_ansible_inventory/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for create_ansible_inventory
|
38
roles/create_etc_hosts/README.md
Normal file
38
roles/create_etc_hosts/README.md
Normal file
@ -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).
|
2
roles/create_etc_hosts/defaults/main.yml
Normal file
2
roles/create_etc_hosts/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for create_etc_hosts
|
2
roles/create_etc_hosts/handlers/main.yml
Normal file
2
roles/create_etc_hosts/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for create_etc_hosts
|
52
roles/create_etc_hosts/meta/main.yml
Normal file
52
roles/create_etc_hosts/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.
|
26
roles/create_etc_hosts/tasks/main.yml
Normal file
26
roles/create_etc_hosts/tasks/main.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
- name: Create /etc/hosts for Environment
|
||||||
|
block:
|
||||||
|
- name: "Write /etc/hosts file to {{ etc_hosts_dest }}"
|
||||||
|
template :
|
||||||
|
src : "{{ etc_hosts_tmpl }}"
|
||||||
|
dest : "{{ etc_hosts_dest }}"
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Pause for 10s
|
||||||
|
pause:
|
||||||
|
seconds: 10
|
||||||
|
|
||||||
|
|
||||||
|
- name: Fetch VM info
|
||||||
|
include_role:
|
||||||
|
name: jchristianh.pve.get_vm_ipaddr
|
||||||
|
|
||||||
|
|
||||||
|
- name: "Write /etc/hosts file to {{ etc_hosts_dest }}"
|
||||||
|
template :
|
||||||
|
src : "{{ etc_hosts_tmpl }}"
|
||||||
|
dest : "{{ etc_hosts_dest }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
18
roles/create_etc_hosts/templates/etc_hosts.j2
Normal file
18
roles/create_etc_hosts/templates/etc_hosts.j2
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# {{ template_run_date }}
|
||||||
|
################################
|
||||||
|
# {{ lab_template_header }} #
|
||||||
|
################################
|
||||||
|
#
|
||||||
|
# Configuration : {{ etc_hosts_file }}
|
||||||
|
# Template Version : {{ etc_hosts_ver }}-{{ etc_hosts_rev }}
|
||||||
|
#
|
||||||
|
# {{ __project_maintainer }} <{{ __project_maintainer_email }}>
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
|
||||||
|
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
|
||||||
|
|
||||||
|
|
||||||
|
{% for node in r_hosts_inventory %}
|
||||||
|
{{ node.address }} {{ node.name }} {{ node.name }}.{{ __pve_tld }}
|
||||||
|
{% endfor %}
|
2
roles/create_etc_hosts/tests/inventory
Normal file
2
roles/create_etc_hosts/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/create_etc_hosts/tests/test.yml
Normal file
5
roles/create_etc_hosts/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- create_etc_hosts
|
2
roles/create_etc_hosts/vars/main.yml
Normal file
2
roles/create_etc_hosts/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for create_etc_hosts
|
38
roles/create_snapshots/README.md
Normal file
38
roles/create_snapshots/README.md
Normal file
@ -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).
|
2
roles/create_snapshots/defaults/main.yml
Normal file
2
roles/create_snapshots/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for create_snapshots
|
2
roles/create_snapshots/handlers/main.yml
Normal file
2
roles/create_snapshots/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for create_snapshots
|
52
roles/create_snapshots/meta/main.yml
Normal file
52
roles/create_snapshots/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.
|
44
roles/create_snapshots/tasks/main.yml
Normal file
44
roles/create_snapshots/tasks/main.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
- name: Check if desired snapshot exists in PVE
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/{{ item.vmid }}/snapshot/{{ __lab_snapshot_name }}/config"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
node : "{{ item.vm_host | default(__pve_node) }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
status_code :
|
||||||
|
- 200
|
||||||
|
- 500
|
||||||
|
register : r_snapshot_list
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Create VM snapshot if one doesn't exist
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.item.vm_host | default(__pve_node) }}/qemu/{{ item.item.vmid }}/snapshot"
|
||||||
|
method : POST
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
body_format : form-urlencoded
|
||||||
|
body :
|
||||||
|
node : "{{ item.item.vm_host | default(__pve_node) }}"
|
||||||
|
vmid : "{{ item.item.vmid }}"
|
||||||
|
snapname : "{{ __lab_snapshot_name }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_snapshot_create
|
||||||
|
loop : "{{ r_snapshot_list.results }}"
|
||||||
|
loop_control :
|
||||||
|
label : "[{{ item.item.vmid }}] {{ item.item.name }}"
|
||||||
|
when :
|
||||||
|
- item.msg is search("Error")
|
||||||
|
|
||||||
|
|
||||||
|
...
|
2
roles/create_snapshots/tests/inventory
Normal file
2
roles/create_snapshots/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/create_snapshots/tests/test.yml
Normal file
5
roles/create_snapshots/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- create_snapshots
|
2
roles/create_snapshots/vars/main.yml
Normal file
2
roles/create_snapshots/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for create_snapshots
|
38
roles/create_vms/README.md
Normal file
38
roles/create_vms/README.md
Normal file
@ -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).
|
2
roles/create_vms/defaults/main.yml
Normal file
2
roles/create_vms/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for create_vms
|
2
roles/create_vms/handlers/main.yml
Normal file
2
roles/create_vms/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for create_vms
|
52
roles/create_vms/meta/main.yml
Normal file
52
roles/create_vms/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.
|
45
roles/create_vms/tasks/main.yml
Normal file
45
roles/create_vms/tasks/main.yml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
- name: Fetch VM list from API
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/{{ item.vmid }}/config"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
node : "{{ item.vm_host | default(__pve_node) }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
status_code :
|
||||||
|
- 200
|
||||||
|
- 500
|
||||||
|
register : r_get_vm_list
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Create VMs
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ __pve_node }}/qemu/\
|
||||||
|
{{ item.item.vm_template_id | default(__vm_tmpl_id) }}/clone"
|
||||||
|
method : POST
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
body_format : form-urlencoded
|
||||||
|
body:
|
||||||
|
vmid : "{{ item.item.vm_template_id | default(__vm_tmpl_id) }}"
|
||||||
|
newid : "{{ item.item.vmid }}"
|
||||||
|
name : "{{ item.item.name }}"
|
||||||
|
target : "{{ item.item.vm_host | default(__pve_node) }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_create_vm
|
||||||
|
loop : "{{ r_get_vm_list.results }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.item.name }}"
|
||||||
|
when :
|
||||||
|
- item.status == 500
|
||||||
|
|
||||||
|
|
||||||
|
...
|
2
roles/create_vms/tests/inventory
Normal file
2
roles/create_vms/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/create_vms/tests/test.yml
Normal file
5
roles/create_vms/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- create_vms
|
2
roles/create_vms/vars/main.yml
Normal file
2
roles/create_vms/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for create_vms
|
38
roles/destroy_vms/README.md
Normal file
38
roles/destroy_vms/README.md
Normal file
@ -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).
|
2
roles/destroy_vms/defaults/main.yml
Normal file
2
roles/destroy_vms/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for destroy_vms
|
2
roles/destroy_vms/handlers/main.yml
Normal file
2
roles/destroy_vms/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for destroy_vms
|
52
roles/destroy_vms/meta/main.yml
Normal file
52
roles/destroy_vms/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.
|
41
roles/destroy_vms/tasks/main.yml
Normal file
41
roles/destroy_vms/tasks/main.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
- name: Verify VM status
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/{{ item.vmid }}/status/current"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
node : "{{ item.vm_host | default(__pve_node) }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_wait_status
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
until : r_wait_status.json.data.status == 'stopped'|lower
|
||||||
|
retries : "{{ __api_retries }}"
|
||||||
|
delay : "{{ __api_polling }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Destroy VMs
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.item.vm_host | default(__pve_node) }}/qemu/{{ item.item.vmid }}"
|
||||||
|
method : DELETE
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
node : "{{ item.vm_host | default(__pve_node) }}"
|
||||||
|
vmid : "{{ item.item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_delete_vm
|
||||||
|
loop : "{{ r_wait_status.results }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.json.data.name }}"
|
||||||
|
when :
|
||||||
|
- item.json.data is defined
|
||||||
|
- item.json.data.status == 'stopped'|lower
|
||||||
|
|
||||||
|
|
||||||
|
...
|
2
roles/destroy_vms/tests/inventory
Normal file
2
roles/destroy_vms/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/destroy_vms/tests/test.yml
Normal file
5
roles/destroy_vms/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- destroy_vms
|
2
roles/destroy_vms/vars/main.yml
Normal file
2
roles/destroy_vms/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for destroy_vms
|
38
roles/generate_vmid/README.md
Normal file
38
roles/generate_vmid/README.md
Normal file
@ -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).
|
2
roles/generate_vmid/defaults/main.yml
Normal file
2
roles/generate_vmid/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for generate_vmid
|
2
roles/generate_vmid/handlers/main.yml
Normal file
2
roles/generate_vmid/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for generate_vmid
|
52
roles/generate_vmid/meta/main.yml
Normal file
52
roles/generate_vmid/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.
|
35
roles/generate_vmid/tasks/main.yml
Normal file
35
roles/generate_vmid/tasks/main.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
#- name: Generate and associate VMID to VM
|
||||||
|
# set_fact :
|
||||||
|
# lab_nodes :
|
||||||
|
# "{{ lab_nodes | combine({ item.name: {'vmid': lab_vmid_base + idx_lab_nodes} }, recursive=True) }}"
|
||||||
|
# loop : "{{ lab_nodes }}"
|
||||||
|
# loop_control :
|
||||||
|
# label : "{{ item.name }}"
|
||||||
|
# index_var : idx_lab_nodes
|
||||||
|
|
||||||
|
|
||||||
|
#- name: Debug lab_nodes
|
||||||
|
# debug :
|
||||||
|
# var : lab_nodes
|
||||||
|
|
||||||
|
|
||||||
|
- name: Generate and associate VMID to VM
|
||||||
|
set_fact:
|
||||||
|
lab_nodes: "{{ lookup('template', 'generate_vmid_lookup.j2') }}"
|
||||||
|
|
||||||
|
|
||||||
|
#- name: Debug lab_nodes
|
||||||
|
# debug :
|
||||||
|
# var : lab_nodes
|
||||||
|
|
||||||
|
|
||||||
|
#- name: Debug lab_nodes again
|
||||||
|
# debug :
|
||||||
|
# msg : "{{ item.name }} -> {{ item.vmid }}"
|
||||||
|
# loop: "{{ lab_nodes }}"
|
||||||
|
# loop_control:
|
||||||
|
# label: "{{ item.name }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
13
roles/generate_vmid/templates/generate_vmid_lookup.j2
Normal file
13
roles/generate_vmid/templates/generate_vmid_lookup.j2
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[
|
||||||
|
{% for lab_node in lab_nodes %}
|
||||||
|
{
|
||||||
|
"name" : "{{ lab_node.name }}",
|
||||||
|
"vmid" : "{{ lab_vmid_base + (loop.index - 1) }}",
|
||||||
|
"vm_host" : "{{ lab_node.vm_host | default(__pve_node) }}",
|
||||||
|
"vm_template_id" : "{{ lab_node.vm_template_id | default(__vm_tmpl_id) }}",
|
||||||
|
"group" : "{{ lab_node.group | default(__default_inventory_group) }}",
|
||||||
|
"cores" : "{{ lab_node.cores | default(__lab_cores_default) }}",
|
||||||
|
"mem" : {{ lab_node.mem | default(__lab_mem_default) }},
|
||||||
|
},
|
||||||
|
{% endfor %}
|
||||||
|
]
|
2
roles/generate_vmid/tests/inventory
Normal file
2
roles/generate_vmid/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/generate_vmid/tests/test.yml
Normal file
5
roles/generate_vmid/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- generate_vmid
|
2
roles/generate_vmid/vars/main.yml
Normal file
2
roles/generate_vmid/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for generate_vmid
|
38
roles/get_vm_ipaddr/README.md
Normal file
38
roles/get_vm_ipaddr/README.md
Normal file
@ -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).
|
2
roles/get_vm_ipaddr/defaults/main.yml
Normal file
2
roles/get_vm_ipaddr/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for get_vm_ipaddr
|
2
roles/get_vm_ipaddr/handlers/main.yml
Normal file
2
roles/get_vm_ipaddr/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for get_vm_ipaddr
|
52
roles/get_vm_ipaddr/meta/main.yml
Normal file
52
roles/get_vm_ipaddr/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.
|
55
roles/get_vm_ipaddr/tasks/main.yml
Normal file
55
roles/get_vm_ipaddr/tasks/main.yml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
- name: Get network info from API
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/{{ item.vmid }}/agent/network-get-interfaces"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
node : "{{ item.vm_host | default(__pve_node) }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_network_interfaces
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control:
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
until : r_network_interfaces.status == 200
|
||||||
|
retries : "{{ __api_retries }}"
|
||||||
|
delay : "{{ __api_polling }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Process API information
|
||||||
|
block:
|
||||||
|
- name: Process results from API
|
||||||
|
set_fact:
|
||||||
|
r_hosts_inventory: "{{ lookup('template', 'get_vm_ip_lookup.j2') }}"
|
||||||
|
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Retry fetching network info from API
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/{{ item.vmid }}/agent/network-get-interfaces"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
node : "{{ item.vm_host | default(__pve_node) }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_network_interfaces
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control:
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
until : r_network_interfaces.status == 200
|
||||||
|
retries : "{{ __api_retries }}"
|
||||||
|
delay : "{{ __api_polling }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Process results from API
|
||||||
|
set_fact:
|
||||||
|
r_hosts_inventory: "{{ lookup('template', 'get_vm_ip_lookup.j2') }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
19
roles/get_vm_ipaddr/templates/get_vm_ip_lookup.j2
Normal file
19
roles/get_vm_ipaddr/templates/get_vm_ip_lookup.j2
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[
|
||||||
|
{% for node in r_network_interfaces.results %}
|
||||||
|
{
|
||||||
|
"name" : "{{ node.item.name }}",
|
||||||
|
"vmid" : "{{ node.item.vmid }}",
|
||||||
|
"vm_host" : "{{ node.item.vm_host | default(__pve_node) }}",
|
||||||
|
"group" : "{{ node.item.group }}",
|
||||||
|
{% for interfaces in node.json.data.result %}
|
||||||
|
{% if interfaces.name != 'lo' %}
|
||||||
|
{% for addr in interfaces["ip-addresses"] %}
|
||||||
|
{% if addr["ip-address-type"] == "ipv4" %}
|
||||||
|
"address" : "{{ addr["ip-address"] }}",
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
},
|
||||||
|
{% endfor %}
|
||||||
|
]
|
2
roles/get_vm_ipaddr/tests/inventory
Normal file
2
roles/get_vm_ipaddr/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/get_vm_ipaddr/tests/test.yml
Normal file
5
roles/get_vm_ipaddr/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- get_vm_ipaddr
|
2
roles/get_vm_ipaddr/vars/main.yml
Normal file
2
roles/get_vm_ipaddr/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for get_vm_ipaddr
|
38
roles/rollback_vms/README.md
Normal file
38
roles/rollback_vms/README.md
Normal file
@ -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).
|
2
roles/rollback_vms/defaults/main.yml
Normal file
2
roles/rollback_vms/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for rollback_vms
|
2
roles/rollback_vms/handlers/main.yml
Normal file
2
roles/rollback_vms/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for rollback_vms
|
52
roles/rollback_vms/meta/main.yml
Normal file
52
roles/rollback_vms/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.
|
42
roles/rollback_vms/tasks/main.yml
Normal file
42
roles/rollback_vms/tasks/main.yml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
- name: Rollback VMs to initial state
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/{{ item.vmid }}/snapshot/{{ __lab_snapshot_name }}/rollback"
|
||||||
|
method : POST
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
body_format : form-urlencoded
|
||||||
|
body:
|
||||||
|
node : "{{ item.vm_host | default(__pve_node) }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
snapname : "{{ __lab_snapshot_name }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_rollback_vms
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "[{{ item.vmid }}] {{ item.name }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Wait for rollback completion...
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/\
|
||||||
|
{{ item.vmid }}/status/current"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_wait_for_rollback
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
until : r_wait_for_rollback.status == 200 and r_wait_for_rollback.json.data.status is defined
|
||||||
|
retries : "{{ __api_retries }}"
|
||||||
|
delay : "{{ __api_polling }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
2
roles/rollback_vms/tests/inventory
Normal file
2
roles/rollback_vms/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/rollback_vms/tests/test.yml
Normal file
5
roles/rollback_vms/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- rollback_vms
|
2
roles/rollback_vms/vars/main.yml
Normal file
2
roles/rollback_vms/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for rollback_vms
|
38
roles/shutdown_vms/README.md
Normal file
38
roles/shutdown_vms/README.md
Normal file
@ -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).
|
2
roles/shutdown_vms/defaults/main.yml
Normal file
2
roles/shutdown_vms/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for shutdown_vms
|
2
roles/shutdown_vms/handlers/main.yml
Normal file
2
roles/shutdown_vms/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for shutdown_vms
|
52
roles/shutdown_vms/meta/main.yml
Normal file
52
roles/shutdown_vms/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.
|
41
roles/shutdown_vms/tasks/main.yml
Normal file
41
roles/shutdown_vms/tasks/main.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
- name: Fetch VM status
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/\
|
||||||
|
{{ item.vmid }}/status/current"
|
||||||
|
method : GET
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
vmid : "{{ item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_fetch_status
|
||||||
|
loop : "{{ lab_nodes }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.name }}"
|
||||||
|
until : r_fetch_status.status == 200 and r_fetch_status.json.data.status is defined
|
||||||
|
retries : "{{ __api_retries }}"
|
||||||
|
delay : "{{ __api_polling }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Shutdown VMs
|
||||||
|
uri:
|
||||||
|
url : "{{ __pve_endpoint }}/nodes/{{ item.item.vm_host | default(__pve_node) }}/qemu/\
|
||||||
|
{{ item.item.vmid }}/status/shutdown"
|
||||||
|
method : POST
|
||||||
|
headers :
|
||||||
|
Content-type : "application/x-www-form-urlencoded"
|
||||||
|
Authorization : "{{ __pve_token }}"
|
||||||
|
vmid : "{{ item.item.vmid }}"
|
||||||
|
return_content : no
|
||||||
|
validate_certs : no
|
||||||
|
register : r_start_vm
|
||||||
|
loop : "{{ r_fetch_status.results }}"
|
||||||
|
loop_control :
|
||||||
|
label : "{{ item.json.data.name }}"
|
||||||
|
when :
|
||||||
|
- item.json.data.status == 'running'|lower
|
||||||
|
|
||||||
|
|
||||||
|
...
|
2
roles/shutdown_vms/tests/inventory
Normal file
2
roles/shutdown_vms/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/shutdown_vms/tests/test.yml
Normal file
5
roles/shutdown_vms/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- shutdown_vms
|
2
roles/shutdown_vms/vars/main.yml
Normal file
2
roles/shutdown_vms/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for shutdown_vms
|
38
roles/ssh_keygen/README.md
Normal file
38
roles/ssh_keygen/README.md
Normal file
@ -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).
|
2
roles/ssh_keygen/defaults/main.yml
Normal file
2
roles/ssh_keygen/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for ssh_keygen
|
2
roles/ssh_keygen/handlers/main.yml
Normal file
2
roles/ssh_keygen/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for ssh_keygen
|
52
roles/ssh_keygen/meta/main.yml
Normal file
52
roles/ssh_keygen/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.
|
9
roles/ssh_keygen/tasks/main.yml
Normal file
9
roles/ssh_keygen/tasks/main.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: Generate SSH keypair for Environment
|
||||||
|
community.crypto.openssh_keypair:
|
||||||
|
path: "{{ __ssh_keypair_dest }}/{{ __ssh_keypair_name }}"
|
||||||
|
type: "{{ __ssh_keypair_type }}"
|
||||||
|
size: "{{ __ssh_keypair_size|int }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
2
roles/ssh_keygen/tests/inventory
Normal file
2
roles/ssh_keygen/tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
roles/ssh_keygen/tests/test.yml
Normal file
5
roles/ssh_keygen/tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- ssh_keygen
|
2
roles/ssh_keygen/vars/main.yml
Normal file
2
roles/ssh_keygen/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for ssh_keygen
|
38
roles/start_vms/README.md
Normal file
38
roles/start_vms/README.md
Normal file
@ -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).
|
2
roles/start_vms/defaults/main.yml
Normal file
2
roles/start_vms/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for start_vms
|
2
roles/start_vms/handlers/main.yml
Normal file
2
roles/start_vms/handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for start_vms
|
52
roles/start_vms/meta/main.yml
Normal file
52
roles/start_vms/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.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user