commit
7cfcca0b08
18 changed files with 263 additions and 0 deletions
@ -0,0 +1,7 @@ |
|||||||
|
*.retry |
||||||
|
*/__pycache__ |
||||||
|
*.pyc |
||||||
|
.cache |
||||||
|
.venv |
||||||
|
.env.yml |
||||||
|
docker-compose.yml |
@ -0,0 +1,33 @@ |
|||||||
|
--- |
||||||
|
# Based on ansible-lint config |
||||||
|
extends: default |
||||||
|
|
||||||
|
rules: |
||||||
|
braces: |
||||||
|
max-spaces-inside: 1 |
||||||
|
level: error |
||||||
|
brackets: |
||||||
|
max-spaces-inside: 1 |
||||||
|
level: error |
||||||
|
colons: |
||||||
|
max-spaces-after: -1 |
||||||
|
level: error |
||||||
|
commas: |
||||||
|
max-spaces-after: -1 |
||||||
|
level: error |
||||||
|
comments: disable |
||||||
|
comments-indentation: disable |
||||||
|
document-start: disable |
||||||
|
empty-lines: |
||||||
|
max: 3 |
||||||
|
level: error |
||||||
|
hyphens: |
||||||
|
level: error |
||||||
|
indentation: disable |
||||||
|
key-duplicates: enable |
||||||
|
line-length: disable |
||||||
|
new-line-at-end-of-file: disable |
||||||
|
new-lines: |
||||||
|
type: unix |
||||||
|
trailing-spaces: disable |
||||||
|
truthy: disable |
@ -0,0 +1,32 @@ |
|||||||
|
Role Name |
||||||
|
========= |
||||||
|
|
||||||
|
Simple demo role to view generic variables. It allows you to view a message with a programmatically-defined variable |
||||||
|
|
||||||
|
Role Variables |
||||||
|
-------------- |
||||||
|
|
||||||
|
- `my_role` is the prefix looked-up for the displayed message |
||||||
|
- `{{ my_role }}_text` the text to be displayed |
||||||
|
|
||||||
|
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 |
||||||
|
vars: |
||||||
|
my_role: app |
||||||
|
app_text: "This is a text for my [app]" |
||||||
|
roles: |
||||||
|
- "laurivan.generic_test" |
||||||
|
|
||||||
|
License |
||||||
|
------- |
||||||
|
|
||||||
|
MIT |
||||||
|
|
||||||
|
Author Information |
||||||
|
------------------ |
||||||
|
|
||||||
|
This role was created in 2023 by [Laur Ivan](https://www.laurivan.com). |
@ -0,0 +1,4 @@ |
|||||||
|
--- |
||||||
|
# defaults file for generic_test |
||||||
|
my_role: "generic_test" |
||||||
|
generic_test_text: "Default text for generic_test role" |
@ -0,0 +1,2 @@ |
|||||||
|
--- |
||||||
|
# handlers file for generic_test |
@ -0,0 +1,53 @@ |
|||||||
|
galaxy_info: |
||||||
|
author: Laur Ivan |
||||||
|
namespace: laurivan |
||||||
|
description: Test dynamic findings of variables |
||||||
|
role_name: generic_test |
||||||
|
|
||||||
|
# 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: MIT |
||||||
|
|
||||||
|
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,15 @@ |
|||||||
|
*********************************** |
||||||
|
Delegated driver installation guide |
||||||
|
*********************************** |
||||||
|
|
||||||
|
Requirements |
||||||
|
============ |
||||||
|
|
||||||
|
This driver is delegated to the developer. Up to the developer to implement |
||||||
|
requirements. |
||||||
|
|
||||||
|
Install |
||||||
|
======= |
||||||
|
|
||||||
|
This driver is delegated to the developer. Up to the developer to implement |
||||||
|
requirements. |
@ -0,0 +1,23 @@ |
|||||||
|
--- |
||||||
|
- name: Converge |
||||||
|
hosts: localhost |
||||||
|
gather_facts: false |
||||||
|
vars: |
||||||
|
super_app_text: "Super App message" |
||||||
|
buggy_app_text: "I don't have bugs!" |
||||||
|
tasks: |
||||||
|
- name: "Include laurivan.generic_test" |
||||||
|
ansible.builtin.include_role: |
||||||
|
name: "laurivan.generic_test" |
||||||
|
|
||||||
|
- name: "Include laurivan.generic_test" |
||||||
|
vars: |
||||||
|
my_role: "super_app" |
||||||
|
ansible.builtin.include_role: |
||||||
|
name: "laurivan.generic_test" |
||||||
|
|
||||||
|
- name: "Include laurivan.generic_test" |
||||||
|
vars: |
||||||
|
my_role: "buggy_app" |
||||||
|
ansible.builtin.include_role: |
||||||
|
name: "laurivan.generic_test" |
@ -0,0 +1,35 @@ |
|||||||
|
--- |
||||||
|
- name: Create |
||||||
|
hosts: localhost |
||||||
|
connection: local |
||||||
|
gather_facts: false |
||||||
|
no_log: "{{ molecule_no_log }}" |
||||||
|
tasks: |
||||||
|
|
||||||
|
# TODO: Developer must implement and populate 'server' variable |
||||||
|
|
||||||
|
- when: server.changed | default(false) | bool |
||||||
|
block: |
||||||
|
- name: Populate instance config dict |
||||||
|
ansible.builtin.set_fact: |
||||||
|
instance_conf_dict: { |
||||||
|
'instance': "{{ }}", |
||||||
|
'address': "{{ }}", |
||||||
|
'user': "{{ }}", |
||||||
|
'port': "{{ }}", |
||||||
|
'identity_file': "{{ }}", } |
||||||
|
with_items: "{{ server.results }}" |
||||||
|
register: instance_config_dict |
||||||
|
|
||||||
|
- name: Convert instance config dict to a list |
||||||
|
ansible.builtin.set_fact: |
||||||
|
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" |
||||||
|
|
||||||
|
- name: Dump instance config |
||||||
|
ansible.builtin.copy: |
||||||
|
content: | |
||||||
|
# Molecule managed |
||||||
|
|
||||||
|
{{ instance_conf | to_json | from_json | to_yaml }} |
||||||
|
dest: "{{ molecule_instance_config }}" |
||||||
|
mode: 0600 |
@ -0,0 +1,24 @@ |
|||||||
|
--- |
||||||
|
- name: Destroy |
||||||
|
hosts: localhost |
||||||
|
connection: local |
||||||
|
gather_facts: false |
||||||
|
no_log: "{{ molecule_no_log }}" |
||||||
|
tasks: |
||||||
|
# Developer must implement. |
||||||
|
|
||||||
|
# Mandatory configuration for Molecule to function. |
||||||
|
|
||||||
|
- name: Populate instance config |
||||||
|
ansible.builtin.set_fact: |
||||||
|
instance_conf: {} |
||||||
|
|
||||||
|
- name: Dump instance config |
||||||
|
ansible.builtin.copy: |
||||||
|
content: | |
||||||
|
# Molecule managed |
||||||
|
|
||||||
|
{{ instance_conf | to_json | from_json | to_yaml }} |
||||||
|
dest: "{{ molecule_instance_config }}" |
||||||
|
mode: 0600 |
||||||
|
when: server.changed | default(false) | bool |
@ -0,0 +1,11 @@ |
|||||||
|
--- |
||||||
|
dependency: |
||||||
|
name: galaxy |
||||||
|
driver: |
||||||
|
name: delegated |
||||||
|
platforms: |
||||||
|
- name: instance |
||||||
|
provisioner: |
||||||
|
name: ansible |
||||||
|
verifier: |
||||||
|
name: ansible |
@ -0,0 +1,10 @@ |
|||||||
|
--- |
||||||
|
# This is an example playbook to execute Ansible tests. |
||||||
|
|
||||||
|
- name: Verify |
||||||
|
hosts: all |
||||||
|
gather_facts: false |
||||||
|
tasks: |
||||||
|
- name: Example assertion |
||||||
|
ansible.builtin.assert: |
||||||
|
that: true |
@ -0,0 +1,5 @@ |
|||||||
|
--- |
||||||
|
# tasks file for generic_test |
||||||
|
- name: Display message based on prefix variable |
||||||
|
ansible.builtin.debug: |
||||||
|
msg: "{{ lookup('vars', my_role ~ '_text') }}" |
@ -0,0 +1,2 @@ |
|||||||
|
localhost |
||||||
|
|
@ -0,0 +1,5 @@ |
|||||||
|
--- |
||||||
|
- hosts: localhost |
||||||
|
remote_user: root |
||||||
|
roles: |
||||||
|
- generic_test |
@ -0,0 +1,2 @@ |
|||||||
|
--- |
||||||
|
# vars file for generic_test |
Loading…
Reference in new issue