mirror of
https://github.com/rocky-linux/ansible-role-kojid.git
synced 2024-11-21 20:51:26 +00:00
Initial commit
This commit is contained in:
commit
fc4ce8359c
5
.ansible-lint
Normal file
5
.ansible-lint
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
warn_list:
|
||||||
|
- '204' # Lines should be less than 160 characters
|
||||||
|
- '701' # meta/main.yml should contain relevant info
|
||||||
|
skip_list:
|
||||||
|
- '106' # Role name must match ^[a-z][a-z0-9_]+$ pattern
|
33
.pre-commit-config.yaml
Normal file
33
.pre-commit-config.yaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v3.3.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-json
|
||||||
|
- id: pretty-format-json
|
||||||
|
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: ansible-lint
|
||||||
|
name: Ansible-lint
|
||||||
|
description: This hook runs ansible-lint.
|
||||||
|
entry: ansible-lint --force-color
|
||||||
|
language: python
|
||||||
|
# do not pass files to ansible-lint, see:
|
||||||
|
# https://github.com/ansible/ansible-lint/issues/611
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
|
||||||
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
|
rev: v1.24.2
|
||||||
|
hooks:
|
||||||
|
- id: yamllint
|
||||||
|
files: \.(yaml|yml)$
|
||||||
|
types: [file, yaml]
|
||||||
|
entry: yamllint
|
11
.yamllint
Normal file
11
.yamllint
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
line-length:
|
||||||
|
max: 140
|
||||||
|
level: warning
|
||||||
|
|
||||||
|
ignore: |
|
||||||
|
.travis.yml
|
||||||
|
.github
|
18
CHANGELOG.md
Normal file
18
CHANGELOG.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
- what do we need to do
|
||||||
|
|
||||||
|
## [0.0.1] - 2020-12-13
|
||||||
|
### Added
|
||||||
|
- Initial
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- None
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- None
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Darkbat91
|
||||||
|
|
||||||
|
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.
|
40
README.md
Normal file
40
README.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
CI Badge
|
||||||
|
|
||||||
|
# Ansible template role
|
||||||
|
basic Role to use going forward because I forget pieces
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
Ensure all dependencies are installed and then follow the below process
|
||||||
|
1. `git clone repo` Get the development repository
|
||||||
|
2. `pre-commit install` Install the pre-commit hooks
|
||||||
|
3. Make edits as explained in the customization section
|
||||||
|
4. `pre-commit` Make sure existing code is good
|
||||||
|
5. `do development` Dont ask me :D
|
||||||
|
6. `pre-commit` Make sure the edits are good to go
|
||||||
|
7. `molecule converge`
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
This repo expects 3 things installed on the local machine
|
||||||
|
1. [pre-commit](https://pre-commit.com/) Methodology to test yaml style
|
||||||
|
2. [ansible-lint](https://github.com/ansible-community/ansible-lint) lint ansible code for best practices
|
||||||
|
3. [yamllint](https://github.com/adrienverge/yamllint) Ensures all yaml is well formed
|
||||||
|
|
||||||
|
### Customization
|
||||||
|
There are a few files that are required to be updated when using this template
|
||||||
|
1. [molecule/requirements.yml](molecule/requirements.yml) - Update with any required roles or collections
|
||||||
|
2. [molecule/default/converge.yml](molecule/default/converge.yml) - update with new role name
|
||||||
|
3. [molecule/default/molecule.yml](molecule/default/molecule.yml) - update with desired distributions and extra playbooks
|
||||||
|
4. [github](github) - Rename to `.github` and push, this will set up yamllint, ansible-lint and a CI check job for the `main` branch
|
||||||
|
1. NOTE: If you are using a SAML token this may fail. You can created the files within the Github web app
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
The github actions are configured to automatically run the molecule tests but if you want to load them locally you will also need molecule installed on the development machine
|
||||||
|
|
||||||
|
## Advanced
|
||||||
|
|
||||||
|
There are numerous other options within the [defaults/main.yml](./defaults/main.yml) that can change other parts of the behavior of the system
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
The [changelog](./CHANGELOG.md) is stored externally
|
||||||
|
|
||||||
|
|
2
defaults/main.yml
Normal file
2
defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# ansible default variables - most variables live here
|
33
github/workflows/ansible-lint.yml
Normal file
33
github/workflows/ansible-lint.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
# https://github.com/ansible/ansible-lint-action
|
||||||
|
name: Ansible Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '**.yml'
|
||||||
|
- '**.yaml'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ansible-lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 7
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Git checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Add installed collections in Ansible configuration
|
||||||
|
run: |
|
||||||
|
echo '[defaults]' > ansible.cfg
|
||||||
|
echo 'collections_paths = ./collections' >> ansible.cfg
|
||||||
|
- name: Install role requirements
|
||||||
|
run: ansible-galaxy role install -r molecule/requirements.yml
|
||||||
|
# TODO: Figure out how to get this not to error so this action is universal
|
||||||
|
# - name: Install collection requirements
|
||||||
|
# run: ansible-galaxy collection install -r molecule/requirements.yml
|
||||||
|
|
||||||
|
- name: Ansible Lint
|
||||||
|
uses: rocky-linux/ansible-lint-action@master
|
||||||
|
with:
|
||||||
|
args: "--exclude .github"
|
39
github/workflows/main.yml
Normal file
39
github/workflows/main.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
'on':
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
schedule:
|
||||||
|
- cron: "30 6 * * 2"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
molecule:
|
||||||
|
name: Molecule
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- distro: centos7
|
||||||
|
playbook: converge.yml
|
||||||
|
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: pip3 install ansible molecule[docker] docker
|
||||||
|
|
||||||
|
- name: Run Molecule tests.
|
||||||
|
run: molecule test
|
||||||
|
env:
|
||||||
|
PY_COLORS: '1'
|
||||||
|
ANSIBLE_FORCE_COLOR: '1'
|
||||||
|
MOLECULE_DISTRO: ${{ matrix.distro }}
|
||||||
|
MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
|
21
github/workflows/yaml-lint.yml
Normal file
21
github/workflows/yaml-lint.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
# https://github.com/ibiqlik/action-yamllint
|
||||||
|
name: YAML Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '**.yml'
|
||||||
|
- '**.yaml'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
yamllint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 1
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Git checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: yamllint
|
||||||
|
uses: ibiqlik/action-yamllint@v3
|
53
meta/main.yml
Normal file
53
meta/main.yml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
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: MIT
|
||||||
|
|
||||||
|
min_ansible_version: 2.8
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
13
molecule/default/converge.yml
Normal file
13
molecule/default/converge.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Update apt cache.
|
||||||
|
apt: update_cache=true cache_valid_time=600
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: ansible-role-mycoolrole
|
26
molecule/default/molecule.yml
Normal file
26
molecule/default/molecule.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
ignore-certs: true
|
||||||
|
role-file: molecule/requirements.yml
|
||||||
|
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
|
||||||
|
# lint: |
|
||||||
|
# set -e
|
||||||
|
# yamllint .
|
||||||
|
# ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: instance
|
||||||
|
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: true
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
playbooks:
|
||||||
|
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
|
3
molecule/requirements.yml
Normal file
3
molecule/requirements.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
roles:
|
||||||
|
## Deps go here Should be very short and only if Absolutely needed
|
2
tasks/main.yml
Normal file
2
tasks/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# tasks
|
3
vars/main.yml
Normal file
3
vars/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
# vars file - Nothing should really go here but dynamic imports
|
||||||
|
# and truely static items
|
Loading…
Reference in New Issue
Block a user