Initial commit
This commit is contained in:
commit
67a4d566ea
|
|
@ -0,0 +1,78 @@
|
||||||
|
# ansible-generator
|
||||||
|
|
||||||
|
Generate documentation and continuous integration files for an Ansible Role.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
This script loads input from:
|
||||||
|
|
||||||
|
- meta/main.yml*
|
||||||
|
- meta/version.yml
|
||||||
|
- meta/exception.yml
|
||||||
|
- meta/preferences.yml
|
||||||
|
- defaults/main.yml
|
||||||
|
- requirements.yml
|
||||||
|
- molecule/default/prepare.yml
|
||||||
|
- molecule/default/playbook.yml*
|
||||||
|
- molecule/default/verify.yml
|
||||||
|
- meta/logo.png
|
||||||
|
- generate_modules.sh
|
||||||
|
- compatibility.sh
|
||||||
|
- Ansible Galaxy
|
||||||
|
|
||||||
|
(Items with a star are mandatory)
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
This script writes output to:
|
||||||
|
|
||||||
|
- README.md
|
||||||
|
- molecule/default/molecule.yml
|
||||||
|
- CONTRIBUTING.md
|
||||||
|
- SECURITY.md
|
||||||
|
- LICENSE
|
||||||
|
- .travis.yml
|
||||||
|
- tox.ini
|
||||||
|
- .ansible-lint*
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ansible-role-my_role
|
||||||
|
../path/to/generate.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## meta/version.yml
|
||||||
|
|
||||||
|
This optional file can be placed when a role contains a version.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
project_name: Ansible
|
||||||
|
reference: "defaults/main.yml"
|
||||||
|
versions:
|
||||||
|
- name: ansible
|
||||||
|
url: "https://github.com/ansible/ansible/releases"
|
||||||
|
```
|
||||||
|
|
||||||
|
## meta/exception.yml
|
||||||
|
|
||||||
|
This optional file describes why some build are excepted.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
exceptions:
|
||||||
|
- variation: alpine
|
||||||
|
reason: "Not idempotent"
|
||||||
|
```
|
||||||
|
|
||||||
|
## meta/preferences.yml
|
||||||
|
|
||||||
|
This optional file describes how Travis, Tox and Molecule should behave.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
travis_parallel: no
|
||||||
|
tox_versions:
|
||||||
|
- current
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Please contribute
|
||||||
|
|
||||||
|
You can really make a difference by:
|
||||||
|
|
||||||
|
- [Making an issue](https://help.github.com/articles/creating-an-issue/). A well described issue helps a lot. (Have a look at the [known issues](https://github.com/search?q=user%3Arobertdebock+is%3Aissue+state%3Aopen).)
|
||||||
|
- [Making a pull request](https://services.github.com/on-demand/github-cli/open-pull-request-github) when you see the error in code.
|
||||||
|
|
||||||
|
I'll try to help and take every contribution seriously.
|
||||||
|
|
||||||
|
It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software.
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
exclude_paths:
|
||||||
|
- ./meta/version.yml
|
||||||
|
- ./meta/exception.yml
|
||||||
|
- ./meta/preferences.yml
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Playbook**
|
||||||
|
Please paste the playbook you are using. (Consider `requirements.yml` and
|
||||||
|
optionally the command you've invoked.)
|
||||||
|
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
YOUR PLAYBOOK HERE
|
||||||
|
```
|
||||||
|
|
||||||
|
**Output**
|
||||||
|
Show at least the error, possible related output, maybe just all the output.
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Environment**
|
||||||
|
- Control node OS: [e.g. Debian 9] (`cat /etc/os-release`)
|
||||||
|
- Control node Ansible version: [e.g. 2.9.1] (`ansible --version`)
|
||||||
|
- Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`)
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
#!/usr/bin/env ansible-playbook
|
||||||
|
---
|
||||||
|
- name: generate all files
|
||||||
|
hosts: localhost
|
||||||
|
become: no
|
||||||
|
gather_facts: yes
|
||||||
|
vars_files:
|
||||||
|
- vars/main.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: set role_path and role_name
|
||||||
|
set_fact:
|
||||||
|
role_path: "{{ lookup('env', 'PWD') }}"
|
||||||
|
role_name: "{{ lookup('env', 'PWD') | basename | regex_replace('ansible-role-') }}"
|
||||||
|
|
||||||
|
- name: load meta/main.yml
|
||||||
|
include_vars:
|
||||||
|
file: "{{ role_path }}/meta/main.yml"
|
||||||
|
name: meta
|
||||||
|
|
||||||
|
- name: see if meta/version.yml exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/meta/version.yml"
|
||||||
|
register: versionymlstat
|
||||||
|
|
||||||
|
- name: load meta/version.yml
|
||||||
|
include_vars:
|
||||||
|
file: "{{ role_path }}/meta/version.yml"
|
||||||
|
register: versionyml
|
||||||
|
when:
|
||||||
|
- versionymlstat.stat.exists | bool
|
||||||
|
- name: see if meta/exception.yml exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/meta/exception.yml"
|
||||||
|
register: exceptionymlstat
|
||||||
|
|
||||||
|
- name: load meta/exception.yml
|
||||||
|
include_vars:
|
||||||
|
file: "{{ role_path }}/meta/exception.yml"
|
||||||
|
register: exceptionyml
|
||||||
|
when:
|
||||||
|
- exceptionymlstat.stat.exists | bool
|
||||||
|
|
||||||
|
- name: see if meta/logo.png exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/meta/logo.png"
|
||||||
|
register: logo
|
||||||
|
|
||||||
|
- name: see if meta/preferences.yml exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/meta/preferences.yml"
|
||||||
|
register: preferencesymlstat
|
||||||
|
|
||||||
|
- name: load meta/preferences.yml
|
||||||
|
include_vars:
|
||||||
|
file: "{{ role_path }}/meta/preferences.yml"
|
||||||
|
when:
|
||||||
|
- preferencesymlstat.stat.exists | bool
|
||||||
|
|
||||||
|
- name: see if defaults/main.yml exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/defaults/main.yml"
|
||||||
|
register: defaultsmainyml
|
||||||
|
|
||||||
|
- name: load defaults/main.yml
|
||||||
|
slurp:
|
||||||
|
src: "{{ role_path }}/defaults/main.yml"
|
||||||
|
register: variables
|
||||||
|
when:
|
||||||
|
- defaultsmainyml.stat.exists | bool
|
||||||
|
|
||||||
|
- name: check if requirements.yml exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/requirements.yml"
|
||||||
|
register: check_requirements
|
||||||
|
|
||||||
|
- name: load requirements.yml
|
||||||
|
slurp:
|
||||||
|
src: "{{ role_path }}/requirements.yml"
|
||||||
|
register: requirements
|
||||||
|
when:
|
||||||
|
- check_requirements.stat.exists | bool
|
||||||
|
|
||||||
|
- name: set no requirements when none exist
|
||||||
|
set_fact:
|
||||||
|
requirements:
|
||||||
|
content: "{{ '- none' | b64encode }}"
|
||||||
|
when:
|
||||||
|
- not check_requirements.stat.exists
|
||||||
|
|
||||||
|
- name: load molecule/default/playbook.yml
|
||||||
|
slurp:
|
||||||
|
src: "{{ role_path }}/molecule/default/playbook.yml"
|
||||||
|
register: example
|
||||||
|
|
||||||
|
- name: check if molecule/default/prepare.yml exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/molecule/default/prepare.yml"
|
||||||
|
register: check_prepare
|
||||||
|
|
||||||
|
- name: load molecule/default/prepare.yml
|
||||||
|
slurp:
|
||||||
|
src: "{{ role_path }}/molecule/default/prepare.yml"
|
||||||
|
register: prepare
|
||||||
|
when:
|
||||||
|
- check_prepare.stat.exists | bool
|
||||||
|
|
||||||
|
- name: see if molecule/default/verify.yml exists
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/molecule/default/verify.yml"
|
||||||
|
register: verify
|
||||||
|
|
||||||
|
- name: load molecule/default/verify.yml
|
||||||
|
slurp:
|
||||||
|
src: "{{ role_path }}/molecule/default/verify.yml"
|
||||||
|
register: verifyyml
|
||||||
|
when:
|
||||||
|
- verify.stat.exists | bool
|
||||||
|
|
||||||
|
- name: generate modules list
|
||||||
|
command: "{{ playbook_dir }}/scripts/modules.sh"
|
||||||
|
args:
|
||||||
|
chdir: "{{ role_path }}"
|
||||||
|
register: modules
|
||||||
|
changed_when: no
|
||||||
|
|
||||||
|
- name: load ansible galaxy_id
|
||||||
|
shell: "ansible-galaxy info robertdebock.{{ role_name }} | grep ' id: ' | awk '{print $NF}'"
|
||||||
|
register: galaxy_id
|
||||||
|
changed_when: no
|
||||||
|
|
||||||
|
- name: load .travis.yml
|
||||||
|
include_vars:
|
||||||
|
file: "{{ role_path }}/.travis.yml"
|
||||||
|
name: travis
|
||||||
|
|
||||||
|
- name: load compatibility
|
||||||
|
command: "{{ playbook_dir }}/scripts/compatibility.sh"
|
||||||
|
args:
|
||||||
|
chdir: "{{ role_path }}"
|
||||||
|
register: compatibility
|
||||||
|
changed_when: no
|
||||||
|
|
||||||
|
- name: create .github directory
|
||||||
|
file:
|
||||||
|
path: "{{ role_path }}/.github"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: copy file
|
||||||
|
copy:
|
||||||
|
src: "{{ playbook_dir }}/files/{{ item.source }}"
|
||||||
|
dest: "{{ role_path }}/{{ item.dest | default(item.source) }}"
|
||||||
|
with_items:
|
||||||
|
- source: CONTRIBUTING.md
|
||||||
|
- source: ansible-lint
|
||||||
|
dest: .ansible-lint
|
||||||
|
- source: bug_report.md
|
||||||
|
dest: .github/ISSUE_TEMPLATE/bug_report.md
|
||||||
|
- source: feature_request.md
|
||||||
|
dest: .github/ISSUE_TEMPLATE/feature_request.md
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.source }}"
|
||||||
|
|
||||||
|
- name: render file
|
||||||
|
template:
|
||||||
|
src: "{{ playbook_dir}}/templates/{{ item.source }}.j2"
|
||||||
|
dest: "{{ role_path }}/{{ item.dest | default (item.source) }}"
|
||||||
|
with_items:
|
||||||
|
- source: tox.ini
|
||||||
|
- source: settings.yml
|
||||||
|
dest: .github/settings.yml
|
||||||
|
- source: LICENSE-2.0.txt
|
||||||
|
dest: LICENSE
|
||||||
|
- source: SECURITY.md
|
||||||
|
- source: travis.yml
|
||||||
|
dest: .travis.yml
|
||||||
|
- source: molecule.yml
|
||||||
|
- source: README.md
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.source }}"
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "This role has been tested on these [container images](https://hub.docker.com/):"
|
||||||
|
echo ""
|
||||||
|
echo "|container|tag|allow_failures|"
|
||||||
|
echo "|---------|---|--------------|"
|
||||||
|
|
||||||
|
cat .travis.yml | docker run -i --rm jlordiales/jyparser get ".env.matrix" | while read dash distribution tag rest ; do
|
||||||
|
distribution=$(echo ${distribution} | cut -d\" -f2)
|
||||||
|
tag=$(echo ${tag} | cut -d\" -f2)
|
||||||
|
allow_failures=$(cat .travis.yml | docker run -i --rm jlordiales/jyparser get .matrix.allow_failures | grep ${distribution} | grep ${tag} > /dev/null 2>&1 ; if [ "$?" == 0 ] ; then echo "yes" ; else echo "no" ; fi)
|
||||||
|
echo "|${distribution}|${tag:-latest}|${allow_failures}|"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "This role has been tested on these Ansible versions:"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "- $(grep ' previous' tox.ini | awk '{print $2, $3}')"
|
||||||
|
echo "- $(grep ' current' tox.ini | awk '{print $2}')"
|
||||||
|
echo "- $(grep ' next' tox.ini | awk '{print $2}')"
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "---" ; cat tasks/* handlers/* | grep -A1 -E '( )?^- name:' | grep -e '^ ' | grep -v 'block' | cut -d: -f1 | sort | uniq | while read module ; do echo "- ${module}" ; done
|
||||||
|
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {{ ansible_date_time.year }} {{ author }}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
{{ role_name }}
|
||||||
|
=========
|
||||||
|
|
||||||
|
<img src="https://docs.ansible.com/ansible-tower/3.2.4/html_ja/installandreference/_static/images/logo_invert.png" width="10%" height="10%" alt="Ansible logo" align="right"/>{% if logo.stat.exists %}<img src="https://raw.githubusercontent.com/{{ github_namespace }}/ansible-role-{{ role_name }}/master/meta/logo.png" alt="Project logo" width="40" height="40" align="left"/>{% endif %}
|
||||||
|
|
||||||
|
<a href="https://travis-ci.org/{{ travis_namespace }}/ansible-role-{{ role_name }}"> <img src="https://travis-ci.org/{{ travis_namespace }}/ansible-role-{{ role_name }}.svg?branch=master" alt="Build status"/></a> <img src="https://img.shields.io/ansible/role/d/{{ galaxy_id.stdout }}"/> <img src="https://img.shields.io/ansible/quality/{{ galaxy_id.stdout }}"/>
|
||||||
|
|
||||||
|
{{ meta.galaxy_info.description }}
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This example is taken from `molecule/resources/playbook.yml` and is tested on each push, pull request and release.
|
||||||
|
```yaml
|
||||||
|
{{ example.content | b64decode | regex_replace('ansible-role-', galaxy_namespace) }}```
|
||||||
|
|
||||||
|
The machine you are running this on, may need to be prepared, I use this playbook to ensure everything is in place to let the role work.
|
||||||
|
```yaml
|
||||||
|
{% if prepare.content is defined %}
|
||||||
|
{{ prepare.content | b64decode | regex_replace('ansible-role-', '{{ galaxy_namespace }}.') }}```
|
||||||
|
{% else %}
|
||||||
|
No preparation required.
|
||||||
|
```
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if verifyyml.content is defined %}
|
||||||
|
After running this role, this playbook runs to verify that everything works, this may be a good example how you can use this role.
|
||||||
|
```yaml
|
||||||
|
{{ verifyyml.content | b64decode | regex_replace('ansible-role-', '{{ galaxy_namespace }}.') }}
|
||||||
|
```
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles.
|
||||||
|
|
||||||
|
{% if variables.content is defined %}
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
These variables are set in `defaults/main.yml`:
|
||||||
|
```yaml
|
||||||
|
{{ variables.content | b64decode }}```
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
- Access to a repository containing packages, likely on the internet.
|
||||||
|
- A recent version of Ansible. (Tests run on the current, previous and next release of Ansible.)
|
||||||
|
|
||||||
|
The following roles can be installed to ensure all requirements are met, using `ansible-galaxy install -r requirements.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
{{ requirements.content | b64decode }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Context
|
||||||
|
-------
|
||||||
|
|
||||||
|
This role is a part of many compatible roles. Have a look at [the documentation of these roles](https://robertdebock.nl/) for further information.
|
||||||
|
|
||||||
|
Here is an overview of related roles:
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
Compatibility
|
||||||
|
-------------
|
||||||
|
|
||||||
|
{{ compatibility.stdout }}
|
||||||
|
|
||||||
|
{% if exceptions is defined %}
|
||||||
|
Exceptions
|
||||||
|
----------
|
||||||
|
|
||||||
|
Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work:
|
||||||
|
|
||||||
|
| variation | reason |
|
||||||
|
|---------------------------|------------------------|
|
||||||
|
{% for exception in exceptions %}| {{ exception.variation }} | {{ exception.reason }} |
|
||||||
|
{% endfor %}{% endif %}
|
||||||
|
|
||||||
|
{% if versions is defined %}
|
||||||
|
Included version(s)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
This role [refers to a version]({{ reference }}) released by {{ project_name }}. Check the released version(s) here:
|
||||||
|
{% for version in versions %}
|
||||||
|
- [{{ version.name }}]({{ version.url }}).
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
This version reference means a role may get outdated. Monthly tests occur to see if [bit-rot](https://en.wikipedia.org/wiki/Software_rot) occured. If you however find a problem, please create an issue, I'll get on it as soon as possible.{% endif %}
|
||||||
|
|
||||||
|
Testing
|
||||||
|
-------
|
||||||
|
|
||||||
|
[Unit tests](https://travis-ci.org/{{ travis_namespace }}/ansible-role-{{ role_name }}) are done on every commit, pull request, release and periodically.
|
||||||
|
|
||||||
|
If you find issues, please register them in [GitHub](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/issues)
|
||||||
|
|
||||||
|
Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule):
|
||||||
|
|
||||||
|
[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions.
|
||||||
|
[Molecule](https://github.com/ansible/molecule) tests multiple distributions.
|
||||||
|
|
||||||
|
To test using the defaults (any installed ansible version, namespace: `{{ docker_namespace }}`, image: `{{ docker_image }}`, tag: `{{ docker_tag }}`):
|
||||||
|
|
||||||
|
```
|
||||||
|
molecule test
|
||||||
|
|
||||||
|
# Or select a specific image:
|
||||||
|
image=ubuntu molecule test
|
||||||
|
# Or select a specific image and a specific tag:
|
||||||
|
image="debian" tag="stable" tox
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you can test multiple versions of Ansible, and select images:
|
||||||
|
Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `{{ docker_namespace }}`, image: `{{ docker_image }}`, tag: `{{ docker_tag }}`) tests:
|
||||||
|
|
||||||
|
```
|
||||||
|
tox
|
||||||
|
|
||||||
|
# To run CentOS (namespace: `{{ docker_namespace }}`, tag: `{{ docker_tag }}`)
|
||||||
|
image="centos" tox
|
||||||
|
# Or customize more:
|
||||||
|
image="debian" tag="stable" tox
|
||||||
|
```
|
||||||
|
|
||||||
|
Modules
|
||||||
|
-------
|
||||||
|
|
||||||
|
This role uses the following modules:
|
||||||
|
```yaml
|
||||||
|
{{ modules.stdout }}
|
||||||
|
```
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
{{ meta.galaxy_info.license }}
|
||||||
|
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
[{{ meta.galaxy_info.author }}]({{ author_website }})
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Security Policy
|
||||||
|
|
||||||
|
This software implements other software, it's not very likely that this software introduces new vulnerabilities.
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
The current major version is supported. For example if the current version is 3.4.1:
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 3.4.1 | :white_check_mark: |
|
||||||
|
| 3.4.x | :white_check_mark: |
|
||||||
|
| 3.x.x | :white_check_mark: |
|
||||||
|
| 2.0.0 | :x: |
|
||||||
|
| 1.0.0 | :x: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
Please [open an issue](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/issues) describing the vulnerability.
|
||||||
|
|
||||||
|
Tell them where to go, how often they can expect to get an update on a
|
||||||
|
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||||
|
declined, etc.
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
role-file: requirements.yml
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
platforms:
|
||||||
|
- name: "{{ role_name }}-${image:-{{ docker_image }}}-${tag:-{{ docker_tag }}}${TOX_ENVNAME}"
|
||||||
|
image: "${namespace:-{{ docker_namespace }}}/${image:-{{ docker_image }}}:${tag:-{{ docker_tag }}}"
|
||||||
|
command: /sbin/init
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: yes
|
||||||
|
pre_build_image: yes
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
{% if verify.stat.exists %}
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
enabled: no
|
||||||
|
{% endif %}
|
||||||
|
scenario:
|
||||||
|
name: default
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
repository:
|
||||||
|
description: {{ meta.galaxy_info.description }}
|
||||||
|
homepage: {{ author_website }}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
[tox]
|
||||||
|
minversion = 3.7
|
||||||
|
{% if tox_versions is defined %}
|
||||||
|
envlist = py{37}-ansible-{% raw %}{{% endraw %}{% for version in tox_versions %}{{ version }}{% if not loop.last %},{% endif %}{% endfor %}{% raw %}}{% endraw %}
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
envlist = py{37}-ansible-{previous,current,next}
|
||||||
|
{% endif %}
|
||||||
|
skipsdist = true
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
deps =
|
||||||
|
previous: ansible>=2.8, <2.9
|
||||||
|
current: ansible>=2.9
|
||||||
|
next: git+https://github.com/ansible/ansible.git@devel
|
||||||
|
docker
|
||||||
|
molecule
|
||||||
|
commands =
|
||||||
|
molecule test
|
||||||
|
setenv =
|
||||||
|
TOX_ENVNAME={envname}
|
||||||
|
MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname}
|
||||||
|
|
||||||
|
passenv = namespace image tag
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
---
|
||||||
|
language: python
|
||||||
|
|
||||||
|
python:
|
||||||
|
- "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
namespace="{{ docker_namespace }}"
|
||||||
|
matrix:
|
||||||
|
{% for platform in meta.galaxy_info.platforms %}
|
||||||
|
{% if platform.name == "Amazon" %}
|
||||||
|
{% for version in platform.versions %}
|
||||||
|
{% if version == "1" or version == "all" %}
|
||||||
|
- image="amazonlinux" tag="1"
|
||||||
|
{% endif %}
|
||||||
|
{% if version == "Candidate" or version == "all" %}
|
||||||
|
- image="amazonlinux"
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name == "Alpine" %}
|
||||||
|
- image="alpine"
|
||||||
|
- image="alpine" tag="edge"
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name =="ArchLinux" %}
|
||||||
|
# - namespace="archlinux" image="base"
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name =="Debian" %}
|
||||||
|
- image="debian" tag="unstable"
|
||||||
|
- image="debian"
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name == "OpenSUSE" %}
|
||||||
|
- image="opensuse"
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name == "Ubuntu" %}
|
||||||
|
- image="ubuntu"
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name == "EL" %}
|
||||||
|
{% for version in platform.versions %}
|
||||||
|
{% if version != 8 %}
|
||||||
|
{% for tag in meta.galaxy_info.galaxy_tags %}
|
||||||
|
{% if tag == "redhat" %}
|
||||||
|
- image="redhat" tag="{{ version }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if tag == "centos" %}
|
||||||
|
- image="centos" tag="{{ version }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if tag == "oraclelinux" %}
|
||||||
|
- image="oraclelinux" tag="{{ version }}"
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% for tag in meta.galaxy_info.galaxy_tags %}
|
||||||
|
{% if tag == "redhat" %}
|
||||||
|
- image="redhat"
|
||||||
|
{% endif %}
|
||||||
|
{% if tag == "centos" %}
|
||||||
|
- image="centos"
|
||||||
|
{% endif %}
|
||||||
|
{% if tag == "oraclelinux" %}
|
||||||
|
- image="oraclelinux"
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name == "Fedora" %}
|
||||||
|
- image="fedora"
|
||||||
|
- image="fedora" tag="rawhide"
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
{% for platform in meta.galaxy_info.platforms %}
|
||||||
|
{% if platform.name == "Alpine" %}
|
||||||
|
- env: image="alpine" tag="edge"
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name =="Debian" %}
|
||||||
|
- env: image="debian" tag="unstable"
|
||||||
|
{% endif %}
|
||||||
|
{% if platform.name == "Fedora" %}
|
||||||
|
- env: image="fedora" tag="rawhide"
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
cache:
|
||||||
|
- pip
|
||||||
|
|
||||||
|
install:
|
||||||
|
- pip install --upgrade pip
|
||||||
|
- pip install tox
|
||||||
|
|
||||||
|
script:
|
||||||
|
{% if travis_parallel is defined %}
|
||||||
|
{% if not travis_parallel %}
|
||||||
|
- tox
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
- tox --parallel all
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
|
slack:
|
||||||
|
secure: "{{ travis.notifications.slack.secure }}"
|
||||||
|
email: false
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
# Setting to generate files.
|
||||||
|
|
||||||
|
# Settings to Docker containers.
|
||||||
|
docker_namespace: robertdebock
|
||||||
|
docker_image: fedora
|
||||||
|
docker_tag: latest
|
||||||
|
|
||||||
|
# References to travis use a namespace, this is likely your username on Travis.
|
||||||
|
travis_namespace: robertdebock
|
||||||
|
|
||||||
|
# Documentation refers to Ansible Galaxy. this is likely your username on Galaxy.
|
||||||
|
galaxy_namespace: robertdebock
|
||||||
|
|
||||||
|
# Your username/organization name on GitHub.
|
||||||
|
github_namespace: robertdebock
|
||||||
|
|
||||||
|
# Your name and optionally email-address.
|
||||||
|
author: Robert de Bock (robert@meinit.nl)
|
||||||
|
|
||||||
|
# The full URL to your website.
|
||||||
|
author_website: "https://robertdebock.nl/"
|
||||||
Loading…
Reference in New Issue