Skip to content

Commit

Permalink
feature: initialize repository
Browse files Browse the repository at this point in the history
  • Loading branch information
shmileee committed Feb 22, 2022
1 parent 1d8129a commit eb00853
Show file tree
Hide file tree
Showing 24 changed files with 363 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
warn_list:
- '106'
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: CI
'on':
pull_request:
push:
branches:
- main
schedule:
- cron: '30 1 * * 3'

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies
run: pip install ansible-lint[community,yamllint]

- name: Lint code
run: |
yamllint .
ansible-lint
molecule:
name: Molecule
runs-on: ubuntu-latest
defaults:
run:
working-directory: "${{ github.repository }}"
needs:
- lint
strategy:
fail-fast: false
matrix:
include:
- distro: ubuntu2004
ansible-version: '>=2.11.5'

steps:
- name: Check out the codebase
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies
run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker

- name: Run Molecule tests
run: |
molecule test
env:
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_VERBOSITY: '2'
MOLECULE_DEBUG: '1'
MOLECULE_DISTRO: "${{ matrix.distro }}"
PY_COLORS: '1'
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Release
'on':
push:
tags:
- '*'

jobs:

release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the codebase
uses: actions/checkout@v2

- name: Publish to Galaxy
uses: robertdebock/[email protected]
with:
galaxy_api_key: ${{ secrets.ANSIBLE_GALAXY_TOKEN }}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
*/**.DS_Store
._*
.*.sw*
*~
.idea/
.vscode/
*.retry

__pycache__/
*.py[cod]
*$py.class
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
18 changes: 18 additions & 0 deletions .markdownlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"default": true,
"first-header-h1": false,
"first-line-h1": false,
"line_length": false,
"no-multiple-blanks": false,
"fenced-code-language": true,
"no-duplicate-header": {
"siblings_only": true
},
"code-block-style": {
"style": "fenced"
},
"single-trailing-newline": false,
"MD033": {
"allowed_elements": ["a", "pre", "br"]
}
}
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: fix-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/jorisroovers/gitlint
rev: v0.15.1
hooks:
- id: gitlint
args: [--contrib=contrib-title-conventional-commits, --ignore=body-is-missing, --msg-filename]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.28.1
hooks:
- id: markdownlint
exclude: .github/ISSUE_TEMPLATE

- repo: https://github.com/detailyang/pre-commit-shell
rev: v1.0.6
hooks:
- id: shell-lint

- repo: https://github.com/ansible-community/ansible-lint
# This is intentionally being held back because of issues in v5 per
# https://github.com/cisagov/skeleton-ansible-role/issues/69
rev: v5.4.0
hooks:
- id: ansible-lint

- repo: https://github.com/adrienverge/yamllint
rev: v1.26.3
hooks:
- id: yamllint
name: yamllint
description: This hook runs yamllint.
entry: yamllint
language: python
types: [file, yaml]
2 changes: 1 addition & 1 deletion .whitesource
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"minSeverityLevel": "LOW",
"issueType": "DEPENDENCY"
}
}
}
15 changes: 15 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
truthy: disable

ignore: |
.tox/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# ansible-role-template
# ansible-role-template
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# defaults file
---
2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# handlers file
---
18 changes: 18 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# meta file
---
galaxy_info:
namespace: appsilon
role_name: template
author: Appsilon
company: Appsilon
description: Fill this in
license: MIT
min_ansible_version: 2.11.1
platforms:
- name: Ubuntu
versions:
- focal
galaxy_tags:
- development
- system
dependencies: []
9 changes: 9 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
roles:
- ../../../
19 changes: 19 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
playbooks:
prepare: prepare.yml
converge: converge.yml
verify: verify.yml
5 changes: 5 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Prepare
hosts: all
become: true
tasks: []
7 changes: 7 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Verify
hosts: all
become: true
tasks:
- name: include tasks
include: "{{ playbook_dir }}/../../tests/tasks/post.yml"
47 changes: 47 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"extends": [
"config:base"
],
"labels": [
"dependencies"
],
"packageRules": [
{
"automerge": false,
"matchUpdateTypes": [
"patch",
"pin",
"digest",
"minor"
]
},
{
"matchUpdateTypes": [
"major"
],
"reviewers": [
"team:infrastructure-team"
]
},
{
"automerge": false,
"groupName": "dependencies",
"managers": [
"pre-commit",
"ansible",
"github-actions"
],
"matchUpdateTypes": [
"minor",
"patch"
]
}
],
"prConcurrentLimit": 2,
"schedule": [
"every weekday",
"after 9am and before 5pm"
],
"separateMinorPatch": true,
"timezone": "Europe/Warsaw"
}
10 changes: 10 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# tasks file
---
- name: include variables
include_vars: "{{ item }}"
with_first_found:
- "_{{ ansible_distribution_release }}.yml"
- "_{{ ansible_distribution | lower }}.yml"
- _default.yml
tags:
- configuration
24 changes: 24 additions & 0 deletions templates/macros/gcfg_encode_macro.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{#
# Jinja2 macro which converts Ansible map into GCFG format
#}

{%- macro gcfg_encode(
item,
delimiter=" = ",
quote="" ) %}

{%- for section, options in item.items() | sort %}
{%- if options is mapping -%}
{{ "\n[" ~ section ~ "]\n" }}
{%- for property, value in options.items() | sort -%}
{%- if value is string or value is number -%}
{{ property ~ delimiter ~ quote ~ value ~ quote ~ "\n" }}
{%- else %}
{%- for v in value -%}
{{ property ~ delimiter ~ quote ~ v ~ quote ~ "\n" }}
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- endmacro %}
2 changes: 2 additions & 0 deletions tests/tasks/post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# post test file
---
13 changes: 13 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# test file
---
- hosts: localhost
connection: local
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/vars/main.yml"
roles:
- ../../
post_tasks:
- name: include tasks
include: "{{ playbook_dir }}/tasks/post.yml"
2 changes: 2 additions & 0 deletions tests/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# vars file
---
2 changes: 2 additions & 0 deletions vars/_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# vars file
---
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# vars file
---

0 comments on commit eb00853

Please sign in to comment.