From df602f7faab8eb809a97a35e19656f50a07ccf98 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 30 Jan 2020 09:13:03 +0100 Subject: [PATCH] initial commit --- LICENSE | 8 + README.md | 13 ++ cookiecutter.json | 11 ++ hooks/post_gen_project.sh | 1 + .../.drone.jsonnet | 155 ++++++++++++++++++ .../.gitignore | 11 ++ .../.later.yml | 18 ++ .../LICENSE | 8 + .../README.md | 14 ++ .../defaults/main.yml | 1 + .../meta/main.yml | 21 +++ .../molecule/pytest.ini | 3 + .../create.yml | 89 ++++++++++ .../destroy.yml | 56 +++++++ .../molecule.yml | 24 +++ .../playbook.yml | 5 + .../prepare.yml | 9 + .../tests/test_default.py | 11 ++ .../tasks/main.yml | 2 + 19 files changed, 460 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 cookiecutter.json create mode 100644 hooks/post_gen_project.sh create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/.drone.jsonnet create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/.gitignore create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/.later.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/LICENSE create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/README.md create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/defaults/main.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/meta/main.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/pytest.ini create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/create.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/destroy.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/molecule.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/playbook.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/prepare.yml create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/tests/test_default.py create mode 100644 {{cookiecutter.author}}.{{cookiecutter.role_name}}/tasks/main.yml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e9db3a9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +MIT License +Copyright (c) 2020 Robert Kaussow + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2570c6d --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# cookiecutter-ansible-role + +Cookiecutter recipe to easily create ansible roles. + +Usage it with `cookiecutter https://gitea.rknet.org/xoxys/cookiecutter-ansible-role` + +### License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +### Maintainers and Contributors + +[Robert Kaussow](https://gitea.rknet.org/xoxys) diff --git a/cookiecutter.json b/cookiecutter.json new file mode 100644 index 0000000..25c2c0d --- /dev/null +++ b/cookiecutter.json @@ -0,0 +1,11 @@ +{ + "author": "xoxys", + "author_full": "Robert Kaussow", + "author_email": "mail@geeklabor.de", + "role_name": "my_role", + "role_description_short": "My demo role", + "role_min_ansible_version": "2.8", + "molecule_scenario": "centos-8", + "molecule_machine_size": "s-1vcpu-1gb", + "license_year": "{% now 'Europe/Berlin', '%Y' %}" +} diff --git a/hooks/post_gen_project.sh b/hooks/post_gen_project.sh new file mode 100644 index 0000000..f1f641a --- /dev/null +++ b/hooks/post_gen_project.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.drone.jsonnet b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.drone.jsonnet new file mode 100644 index 0000000..5425bda --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.drone.jsonnet @@ -0,0 +1,155 @@ +local PipelineLinting = { + kind: 'pipeline', + name: 'linting', + platform: { + os: 'linux', + arch: 'amd64', + }, + steps: [ + { + name: 'ansible-later', + image: 'xoxys/ansible-later:latest', + commands: [ + 'ansible-later', + ], + }, + ], + trigger: { + ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'], + }, +}; + +local PipelineDeployment(scenario='{{ cookiecutter.molecule_scenario | replace("-", "") }}') = { + kind: 'pipeline', + name: 'testing-' + scenario, + platform: { + os: 'linux', + arch: 'amd64', + }, + concurrency: { + limit: 1, + }, + workspace: { + base: '/drone/src', + path: '{{ cookiecutter.author }}.{{ cookiecutter.role_name }}', + }, + steps: [ + { + name: 'ansible-molecule', + image: 'xoxys/molecule:latest', + environment: { + DO_API_KEY: { from_secret: 'do_api_key' }, + USER: 'root', + MOLECULE_CUSTOM_MODULES_REPO: 'https://gitea.rknet.org/ansible/custom_modules', + MOLECULE_CUSTOM_FILTERS_REPO: 'https://gitea.rknet.org/ansible/custom_filters', + }, + commands: [ + 'molecule test -s' + scenario, + ], + }, + ], + depends_on: [ + 'linting', + ], + trigger: { + ref: ['refs/heads/master', 'refs/tags/**'], + }, +}; + +local PipelineDocumentation = { + kind: 'pipeline', + name: 'documentation', + platform: { + os: 'linux', + arch: 'amd64', + }, + steps: [ + { + name: 'generate', + image: 'xoxys/ansible-doctor:latest', + environment: { + ANSIBLE_DOCTOR_LOG_LEVEL: 'INFO', + ANSIBLE_DOCTOR_FORCE_OVERWRITE: true, + ANSIBLE_DOCTOR_EXCLUDE_FILES: 'molecule/', + ANSIBLE_DOCTOR_TEMPLATE: 'hugo-book', + ANSIBLE_DOCTOR_ROLE_NAME: '${DRONE_REPO_NAME#*.}', + ANSIBLE_DOCTOR_OUTPUT_DIR: '_docs/', + }, + }, + { + name: 'publish', + image: 'plugins/gh-pages:latest', + settings: { + remote_url: 'https://gitea.rknet.org/ansible/{{ cookiecutter.author }}.{{ cookiecutter.role_name }}', + netrc_machine: 'gitea.rknet.org', + username: { from_secret: 'gitea_username' }, + password: { from_secret: 'gitea_token' }, + pages_directory: '_docs/', + target_branch: 'docs', + }, + when: { + ref: ['refs/heads/master'], + }, + }, + { + name: 'trigger', + image: 'plugins/downstream', + settings: { + server: 'https://drone.rknet.org', + token: { from_secret: 'drone_token' }, + fork: true, + repositories: [ + 'ansible/ansible-galaxy', + ], + }, + when: { + ref: ['refs/heads/master'], + }, + }, + ], + trigger: { + ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'], + }, + depends_on: [ + 'testing-{{ cookiecutter.molecule_scenario | replace("-", "") }}', + ], +}; + +local PipelineNotification = { + kind: 'pipeline', + name: 'notification', + platform: { + os: 'linux', + arch: 'amd64', + }, + clone: { + disable: true, + }, + steps: [ + { + name: 'matrix', + image: 'plugins/matrix', + settings: { + homeserver: { from_secret: 'matrix_homeserver' }, + roomid: { from_secret: 'matrix_roomid' }, + template: '{% raw %}Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}{% endraw %}', + username: { from_secret: 'matrix_username' }, + password: { from_secret: 'matrix_password' }, + }, + }, + ], + depends_on: [ + 'documentation', + ], + trigger: { + status: ['success', 'failure'], + ref: ['refs/heads/master', 'refs/tags/**'], + }, +}; + +[ + PipelineLinting, + PipelineDeployment(scenario='{{ cookiecutter.molecule_scenario | replace("-", "") }}'), + PipelineDocumentation, + PipelineNotification, +] diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.gitignore b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.gitignore new file mode 100644 index 0000000..d97b7cd --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.gitignore @@ -0,0 +1,11 @@ +# ---> Ansible +*.retry +plugins +library + +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.later.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.later.yml new file mode 100644 index 0000000..45911c9 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/.later.yml @@ -0,0 +1,18 @@ +--- +ansible: + custom_modules: + - iptables_raw + - openssl_pkcs12 + - proxmox_kvm2 + - ucr + - yum_versionlock + +rules: + exclude_files: + - molecule/ + - "LICENSE*" + - "**/*.md" + - "**/*.ini" + + exclude_filter: + - LINT0009 diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/LICENSE b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/LICENSE new file mode 100644 index 0000000..c054805 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/LICENSE @@ -0,0 +1,8 @@ +MIT License +Copyright (c) {{ cookiecutter.license_year }} {{ cookiecutter.author_full }} <{{ cookiecutter.author_email }}> + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/README.md b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/README.md new file mode 100644 index 0000000..a4429ea --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/README.md @@ -0,0 +1,14 @@ +# {{ cookiecutter.author }}.{{ cookiecutter.role_name }} + +[![Build Status](https://img.shields.io/drone/build/ansible/{{ cookiecutter.author }}.{{ cookiecutter.role_name }}?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/{{ cookiecutter.author }}.{{ cookiecutter.role_name }}) +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE) + +You can find the full documentation at [https://galaxy.geekdocs.de](https://galaxy.geekdocs.de/system/{{ cookiecutter.role_name }}/). + +### License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +### Maintainers and Contributors + +[{{ cookiecutter.author_full }}](https://gitea.rknet.org/{{ cookiecutter.author }}) diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/defaults/main.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/defaults/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/meta/main.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/meta/main.yml new file mode 100644 index 0000000..bad1ca3 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/meta/main.yml @@ -0,0 +1,21 @@ +# Standards: 0.1 +--- +galaxy_info: +# @meta author:value: [{{ cookiecutter.author_full }}](https://gitea.rknet.org/{{ cookiecutter.author }}) + author: "{{ cookiecutter.author_full }} <{{ author_email }}>" +# @meta description: > +# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/{{ cookiecutter.author }}.{{ cookiecutter.role_name }}) +# [![Build Status](https://img.shields.io/drone/build/ansible/{{ cookiecutter.author }}.{{ cookiecutter.role_name }}?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/{{ cookiecutter.author }}.{{ cookiecutter.role_name }}) +# [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE) +# +# {{ cookiecutter.role_description_short }} +# @end + description: {{ cookiecutter.role_description_short }} + license: MIT + min_ansible_version: {{ cookiecutter.role_min_ansible_version }} + platforms: + - name: EL + versions: + - 7 + galaxy_tags: +dependencies: diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/pytest.ini b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/pytest.ini new file mode 100644 index 0000000..c24fe5b --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +filterwarnings = + ignore::DeprecationWarning diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/create.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/create.yml new file mode 100644 index 0000000..9638405 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/create.yml @@ -0,0 +1,89 @@ +--- +{% raw %} +- name: Create + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ molecule_no_log }}" + vars: + ssh_user: root + ssh_port: 22 + + keypair_name: molecule_key + keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" + tasks: + - name: Create local keypair + user: + name: "{{ lookup('env', 'USER') }}" + generate_ssh_key: true + ssh_key_file: "{{ keypair_path }}" + register: local_keypair + + - name: Create remote keypair + digital_ocean_sshkey: + name: "{{ keypair_name }}" + ssh_pub_key: "{{ local_keypair.ssh_public_key }}" + state: present + register: remote_keypair + + - name: Create molecule instance(s) + digital_ocean_droplet: + name: "{{ item.name }}" + unique_name: true + region: "{{ item.region_id }}" + image: "{{ item.image_id }}" + size: "{{ item.size_id }}" + ssh_keys: "{{ remote_keypair.data.ssh_key.id }}" + wait: true + wait_timeout: 300 + state: present + register: server + loop: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) creation to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: digitalocean_jobs + until: digitalocean_jobs.finished + retries: 300 + loop: "{{ server.results }}" + + # Mandatory configuration for Molecule to function. + + - name: Populate instance config dict + set_fact: + instance_conf_dict: { + 'instance': "{{ item.data.droplet.name }}", + 'address': "{{ item.data.ip_address }}", + 'user': "{{ ssh_user }}", + 'port': "{{ ssh_port }}", + 'identity_file': "{{ keypair_path }}", + 'droplet_id': "{{ item.data.droplet.id }}", + 'ssh_key_id': "{{ remote_keypair.data.ssh_key.id }}", + } + loop: "{{ digitalocean_jobs.results }}" + register: instance_config_dict + when: server.changed | bool + + - name: Convert instance config dict to a list + set_fact: + instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" + when: server.changed | bool + + - name: Dump instance config + copy: + content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" + dest: "{{ molecule_instance_config }}" + when: server.changed | bool + + - name: Wait for SSH + wait_for: + port: "{{ ssh_port }}" + host: "{{ item.address }}" + search_regex: SSH + delay: 10 + timeout: 320 + loop: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" +{% endraw %} diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/destroy.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/destroy.yml new file mode 100644 index 0000000..56eded8 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/destroy.yml @@ -0,0 +1,56 @@ +--- +{% raw %} +- name: Destroy + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ molecule_no_log }}" + tasks: + - block: + - name: Populate instance config + set_fact: + instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" + skip_instances: false + rescue: + - name: Populate instance config when file missing + set_fact: + instance_conf: {} + skip_instances: true + + - name: Destroy molecule instance(s) + digital_ocean_droplet: + name: "{{ item.instance }}" + id: "{{ item.droplet_id }}" + state: absent + register: server + loop: "{{ instance_conf | flatten(levels=1) }}" + when: not skip_instances + async: 7200 + poll: 0 + + - name: Wait for instance(s) deletion to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: digitalocean_jobs + until: digitalocean_jobs.finished + retries: 300 + loop: "{{ server.results }}" + + - name: Delete remote keypair + digital_ocean_sshkey: + fingerprint: "{{ item.ssh_key_id }}" + state: absent + loop: "{{ instance_conf | flatten(levels=1) }}" + + # Mandatory configuration for Molecule to function. + + - name: Populate instance config + set_fact: + instance_conf: {} + + - name: Dump instance config + copy: + content: "{{ instance_conf | molecule_to_yaml | molecule_header }}" + dest: "{{ molecule_instance_config }}" + when: server.changed | bool +{% endraw %} diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/molecule.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/molecule.yml new file mode 100644 index 0000000..bda8441 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/molecule.yml @@ -0,0 +1,24 @@ +--- +dependency: + name: galaxy +driver: + name: digitalocean +platforms: + - name: "{{ cookiecutter.molecule_scenario | replace('-', '') }}-{{ cookiecutter.role_name | replace('_', '-') }}" + region_id: fra1 + image_id: "{{ cookiecutter.molecule_scenario }}-x64" + size_id: "{{ cookiecutter.molecule_machine_size }}" +lint: + name: yamllint + enabled: False +provisioner: + name: ansible + lint: + name: ansible-lint + enabled: False +verifier: + name: testinfra + lint: + name: flake8 + options: + max-line-length: 120 diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/playbook.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/playbook.yml new file mode 100644 index 0000000..3ffa49e --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: "{{ cookiecutter.author }}.{{ cookiecutter.role_name }}" diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/prepare.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/prepare.yml new file mode 100644 index 0000000..559de83 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/prepare.yml @@ -0,0 +1,9 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: + - name: Install python for Ansible + raw: test -e /usr/bin/python || (dnf -y install python3 && alternatives --set python /usr/bin/python3) + become: true + changed_when: false diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/tests/test_default.py b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/tests/test_default.py new file mode 100644 index 0000000..7339d3f --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/molecule/{{cookiecutter.molecule_scenario | replace('-', '')}}/tests/test_default.py @@ -0,0 +1,11 @@ +import os + +import testinfra.utils.ansible_runner + +import warnings +warnings.filterwarnings("ignore", category=DeprecationWarning) + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + diff --git a/{{cookiecutter.author}}.{{cookiecutter.role_name}}/tasks/main.yml b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/tasks/main.yml new file mode 100644 index 0000000..9fa4d47 --- /dev/null +++ b/{{cookiecutter.author}}.{{cookiecutter.role_name}}/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# TODO