Compare commits

...

105 commits

Author SHA1 Message Date
nicobo
83d5263110 Added grub_default_options to define GRUB_CMDLINE_LINUX_DEFAULT 2022-03-14 20:57:43 +01:00
nicobo
4ace85d0c9 Value is now optional for options (e.g. 'nomodeset' and not 'nomodeset=...') 2022-03-14 20:56:45 +01:00
nicobo
52cadaa0ec Made grub_timeout and grub_recordfail_timeout optional 2022-03-14 20:22:01 +01:00
Robert de Bock
04777093a3 New version of GitHub Action and a new container for GitLab. 2022-02-14 09:47:44 +01:00
Robert de Bock
5a7385c84d Update GitHub action, simpler GitLab CI. 2022-01-27 11:25:04 +01:00
Robert de Bock
2e7a96e161 Tox will try Ansible 4 and 5. 2022-01-26 13:13:20 +01:00
Robert de Bock
6e280c5f06 No ore ansible-later. 2022-01-25 21:58:38 +01:00
Robert de Bock
5469c0d3db Remove not-required collections, add collections that are required, FQCN. 2022-01-25 21:52:54 +01:00
Robert de Bock
9b24b14981 Both collections are required for now. 2022-01-25 01:54:09 +01:00
Robert de Bock
2f48d692ee Happy 2022! 2022-01-01 11:48:35 +01:00
Robert de Bock
f8e1dac3c0 Quote values with risky characters. 2021-12-06 10:06:31 +01:00
Robert de Bock
cac9ee91b1 Add unquoted value finder. 2021-12-06 10:06:31 +01:00
Robert de Bock
66dd1596bb Test against Fedora 34, 35 (latest) and 36/rawhide. 2021-11-15 15:46:55 +01:00
Robert de Bock
b01c72ceaf Regenerate CI and docs. 2021-10-13 11:47:47 +02:00
Robert de Bock
29c7861c1e Add ansible-later and implement advices. 2021-10-11 17:15:02 +02:00
Robert de Bock
08d65d516e Regenerate CI and docs. 2021-10-07 22:45:24 +02:00
Robert de Bock
a7b8723042 Spread cmd over multiple lines, making the code a little more readable. 2021-09-22 14:08:32 +02:00
Robert de Bock
cc6f27b9d1 The collection community.general is required because apk and zypper. 2021-09-20 09:49:52 +02:00
Robert de Bock
53fdf2a0f3 Add bookwork, combine bullseye+bookwork and focal+bionic to all. 2021-09-15 10:44:50 +02:00
Robert de Bock
8602ff13bb More readable. 2021-09-06 16:37:41 +02:00
Robert de Bock
a95d592458 More patterns for Docker. 2021-08-31 09:46:29 +02:00
Robert de Bock
efa9fbbc58 There are no contributors. 2021-07-06 08:59:22 +02:00
Robert de Bock
8de8c7f2a6 Regenerate CI and docs. 2021-07-05 17:18:39 +02:00
Robert de Bock
5735981cec Drop CentOS 7 Support, its out of regular support. What a moment... 2021-07-01 10:40:17 +02:00
Robert de Bock
9c5b5ef5a2 Regenerate CI and docs. 2021-06-10 09:54:26 +02:00
Robert de Bock
d946c8b5c8 Replace a module name for FQCN. 2021-06-10 09:53:51 +02:00
Robert de Bock
cdf238c5dc More FQCNs 2021-05-27 13:23:15 +02:00
Robert de Bock
78c11572ce Regernerate CI, fix molecule and tox. 2021-05-11 13:26:13 +02:00
Robert de Bock
4b52911e4d Regenerated CI files, to use Fedora 33, 34 and rawhide. 2021-05-04 16:27:06 +02:00
Robert de Bock
6d7858759a Fedora 34 is here, test on Fedora 34 and Rawhide. 2021-04-29 22:00:36 +02:00
Robert de Bock
7d1f961ddc Rename the import appropriately. 2021-04-26 15:00:23 +02:00
Robert de Bock
4ffae7c7a8 Regenerate documents. 2021-03-31 09:26:58 +02:00
Robert de Bock
b8a124d6b6 Introduce collections in molecule too. 2021-03-31 09:26:47 +02:00
Robert de Bock
4b4cde9c72 Start yaml with three dashes. 2021-03-28 12:50:56 +02:00
Robert de Bock
4f3fe7f31f Fix GitLab build-status badge in the documentation. 2021-03-28 12:50:56 +02:00
Robert de Bock
4c0bd748e1 Make unused variable finding work on Mac OS X 2021-03-25 15:31:31 +01:00
Robert de Bock
f364074fbb Please edit meta/main.yml and assure we can correctly determine full role name. 2021-03-11 09:50:02 +01:00
Robert de Bock
26360a1461 Testing for empty directories. 2021-03-09 17:56:17 +01:00
Robert de Bock
c100344c71 Collections FQCN. 2021-02-22 13:59:19 +01:00
Robert de Bock
9015586512 Update requirments to include collections. 2021-02-19 17:28:27 +01:00
Robert de Bock
da222d7eaa Use newer version of Docker image. 2021-02-19 17:28:25 +01:00
Robert de Bock
a369d755fb Ignore .cache too. 2021-02-19 17:28:25 +01:00
Robert de Bock
9c8be0accd Disable anisble-lint for now, it breaks pre-commit. 2021-02-19 17:28:24 +01:00
Robert de Bock
bc5d77a50b Moving to collections instead of modules shipped with Ansible. 2021-02-19 14:08:50 +01:00
Robert de Bock
8244ddde1e Use the latest collection. 2021-02-15 17:46:05 +01:00
Robert de Bock
159ecf185b No rawhide, package GPG issue. 2021-02-15 15:21:53 +01:00
Robert de Bock
e9a353d5c9 Assert on localhost, makes the play stop if the assertion fails. 2021-01-18 09:59:08 +01:00
Robert de Bock
b1ee31df3f drop testing previous, because it does not work with Ansible collections. 2021-01-18 09:59:03 +01:00
Robert de Bock
c31d1cf22a Ansible 2.10 and up are tested 2021-01-18 09:58:57 +01:00
Robert de Bock
de6e5d5108 No Travis, Ansible 2.10. 2021-01-18 09:58:46 +01:00
Robert de Bock
7736a844d4 Prepare fo Ansible 2.10 only. 2021-01-17 13:43:20 +01:00
Robert de Bock
577af9770b Only on master. 2021-01-13 15:59:57 +01:00
Robert de Bock
04da46a182 New version of graphviz action, solves multiple roles in 1 image. 2021-01-13 15:59:52 +01:00
Robert de Bock
04df7e5cfd Use the generated image. 2021-01-12 10:41:22 +01:00
Robert de Bock
1954769b2c Generate an image from requirements.yml 2021-01-12 10:41:18 +01:00
Robert de Bock
5b1fbdde73 It's a new year. 2021-01-12 10:41:13 +01:00
Robert de Bock
bad6722e2d Add pre-commit hooks to find empty files and unused variables. 2021-01-12 10:41:10 +01:00
Robert de Bock
c3dfba9bfb Drop support for Xenial, it's old and too much trouble. 2020-12-17 10:16:57 +01:00
Robert de Bock
8fe82e04cd Add requirements, especially for the Jinja2 requirement. 2020-12-11 14:08:35 +01:00
Robert de Bock
fdba5737de Update documentation. 2020-12-11 14:08:16 +01:00
Robert de Bock
7345e91c75 New version of Molecule action. 2020-12-11 11:33:25 +01:00
Robert de Bock
1d4fdbf903 Add release mechanism for GitLab, retry twice 2020-12-08 09:50:23 +01:00
Robert de Bock
7b5e648136 Update documentation. 2020-12-08 09:50:20 +01:00
Robert de Bock
d03766cf22 Add release mechanism for GitLab. 2020-12-07 10:38:57 +01:00
Robert de Bock
a2efcd57a2 Update documentation. 2020-12-07 10:38:55 +01:00
Robert de Bock
1b4556c805 Update documentation. 2020-12-04 14:19:49 +01:00
Robert de Bock
a855f07290 Add GitLab CI! 2020-12-04 14:17:40 +01:00
Robert de Bock
b89432f0a8 Much simpler, save build-minutes. 2020-12-04 14:17:35 +01:00
Robert de Bock
12fcea5d88 Version 3.9 please. 2020-12-03 17:04:55 +01:00
Robert de Bock
96d4383702 Update molecule action to use newer version of Ansible and Molecule. 2020-12-03 17:04:53 +01:00
Robert de Bock
e313e7fa52 Fedora 33 (running the tests) has python 3.9 and require higher version of tox. 2020-12-03 17:04:50 +01:00
Robert de Bock
f0db7c3211 Test is a defined variable is a string. 2020-11-27 16:32:17 +01:00
Robert de Bock
e920beca01 Add an empty line to improve readability. 2020-11-26 10:22:13 +01:00
Robert de Bock
e6634b803f Empty line to start and dont restart when in checkmode, software is missing. 2020-11-24 20:50:17 +01:00
Robert de Bock
717fad4dd6 Add a new action: todo-to-issue, nice. 2020-11-19 20:11:06 +01:00
Robert de Bock
649460a667 No schedule for releases. 2020-11-19 20:11:01 +01:00
Robert de Bock
490240fd3a Pre-commit, preventing me from making silly mistakes. 2020-11-19 20:10:58 +01:00
Robert de Bock
5af1acefdb Update the Molecule action to run on Ubuntu 20.04. 2020-11-18 13:52:01 +01:00
Robert de Bock
e09608f1f9 Update the Galaxy action ot run on Ubuntu 20.04. 2020-11-18 13:51:58 +01:00
Robert de Bock
ce718f73f6 Since value is already tested for being a number, don't need the int filter. 2020-11-16 11:23:43 +01:00
Robert de Bock
182c25e96c Remove difficult to read and low-value test "| length > 0". 2020-11-16 11:07:32 +01:00
Robert de Bock
9759194404 Assert with "is number" over "| int". 2020-11-11 07:38:31 +01:00
Robert de Bock
d8f75fe5d1 Regenerate CI. 2020-11-06 08:35:12 +01:00
Robert de Bock
959ee144ab List requirements with their build status. 2020-11-06 08:35:09 +01:00
Robert de Bock
f25bb96a87 New format for requirements, prepared for collections. 2020-11-01 20:18:15 +01:00
Robert de Bock
c826541ba7 Use pre-commit. 2020-10-29 15:51:30 +01:00
Robert de Bock
1918370438 Test on Fedora 33! 2020-10-27 21:37:42 +01:00
Robert de Bock
902c3f3a95 Update galaxy action 2020-10-27 21:37:40 +01:00
Robert de Bock
d32a85d2e9 Don't run parallel. 2020-10-16 11:15:39 +02:00
Robert de Bock
2b62233918 Remove "next", it fails with Molecule 3.1, use molecule[docker] and remove MOLECULE_EPHEMERAL_DIRECTORY. 2020-10-15 23:12:35 +02:00
Robert de Bock
d528c582c0 Review tags and ready for hacktoberfest 2020-10-15 23:12:33 +02:00
Robert de Bock
f095435bef Remove unused tags. 2020-10-15 23:12:30 +02:00
Robert de Bock
4ab0b548ff Run the assertions just once, variables are role specific, not host specific. 2020-10-09 10:19:02 +02:00
Robert de Bock
ae20a8d282 Testing on Ansible-2.9 and up. 2020-10-01 16:36:54 +02:00
Robert de Bock
a1600447a9 Regenerated tox.ini 2020-10-01 16:36:51 +02:00
Robert de Bock
e1cd2c75c2 Update docs. 2020-10-01 16:36:49 +02:00
Robert de Bock
fcd10a25f0 Test on Ansible 2.10! (or actually "latest") 2020-09-24 12:12:17 +02:00
Robert de Bock
4d068582d5 Generated README.md 2020-09-22 20:46:40 +02:00
Robert de Bock
f11ca2faad Add ansible-lint to the linting stage. 2020-09-22 10:24:49 +02:00
Robert de Bock
9a3e8a5c48 Update version of molecule-action. 2020-09-22 10:24:47 +02:00
Robert de Bock
3a10c6c63f [208] File permissions not mentioned. 2020-09-17 08:06:56 +02:00
Robert de Bock
b506730119 Use molecule 3.0.8 adviced way of working. 2020-09-01 15:15:07 +02:00
Robert de Bock
93fb3616cd Exclude .tox 2020-09-01 15:15:07 +02:00
Robert de Bock
e330f8f02e Fix slack notifications, implement Travis advices. 2020-09-01 15:15:07 +02:00
Robert de Bock
2430a50260 missing document start "---" 2020-08-27 10:05:55 +02:00
26 changed files with 276 additions and 180 deletions

View file

@ -1,6 +1,12 @@
---
#
# Ansible managed
#
exclude_paths:
- ./meta/preferences.yml
- ./molecule/default/prepare.yml
- ./molecule/default/converge.yml
- ./molecule/default/verify.yml
- ./molecule/default/collections.yml
- ./.tox
- ./.cache

View file

@ -5,6 +5,7 @@ about: Create a report to help me improve
---
## Describe the bug
A clear and concise description of what the bug is.
## Playbook

View file

@ -5,3 +5,4 @@
repository:
description: Configure grub on your system.
homepage: https://robertdebock.nl/
topics: grub, ansible, molecule, tox, playbook, hacktoberfest

View file

@ -6,17 +6,13 @@
name: Release to Ansible Galaxy
on:
push:
tags:
- '*'
schedule:
- cron: '7 7 7 * *'
release:
types: [created, edited, published, released]
jobs:
release:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: galaxy
uses: robertdebock/galaxy-action@1.0.1
uses: robertdebock/galaxy-action@1.1.0
with:
galaxy_api_key: ${{ secrets.galaxy_api_key }}

View file

@ -11,52 +11,48 @@ on:
- '*'
pull_request:
schedule:
- cron: '7 7 7 * *'
- cron: '13 7 7 * *'
jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"
- name: molecule
uses: robertdebock/molecule-action@2.6.1
uses: robertdebock/molecule-action@4.0.7
with:
command: lint
test:
needs:
- lint
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
config:
- image: "alpine"
tag: "latest"
- image: "alpine"
tag: "edge"
- image: "centos"
tag: "7"
- image: "centos"
- image: "enterpriselinux"
tag: "latest"
- image: "debian"
tag: "latest"
- image: "debian"
tag: "bullseye"
tag: "bookworm"
- image: "fedora"
tag: "31"
tag: "34"
- image: "fedora"
tag: "latest"
- image: "fedora"
tag: "rawhide"
- image: "opensuse"
tag: "latest"
- image: "ubuntu"
tag: "latest"
- image: "ubuntu"
tag: "bionic"
- image: "ubuntu"
tag: "xenial"
steps:
- name: checkout
uses: actions/checkout@v2
@ -67,10 +63,7 @@ jobs:
- name: parse apparmor for mysql
run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
- name: molecule
uses: robertdebock/molecule-action@2.6.1
uses: robertdebock/molecule-action@4.0.7
with:
image: ${{ matrix.config.image }}
tag: ${{ matrix.config.tag }}
options: "--parallel all"
env:
TOX_PARALLEL_NO_SPINNER: 1

34
.github/workflows/requirements2png.yml vendored Normal file
View file

@ -0,0 +1,34 @@
---
#
# Ansible managed
#
on:
- push
name: Ansible Graphviz
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: ${{ github.repository }}
- name: create png
uses: robertdebock/graphviz-action@1.0.7
- name: Commit files
run: |
cd ${{ github.repository }}
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add requirements.dot requirements.png
git commit -m "Add generated files"
- name: save to png branch
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: ${{ github.repository }}
force: true
branch: png

20
.github/workflows/todo.yml vendored Normal file
View file

@ -0,0 +1,20 @@
---
#
# Ansible managed
#
name: "TODO 2 Issue"
on:
push:
jobs:
build:
runs-on: "ubuntu-20.04"
steps:
- uses: "actions/checkout@master"
- name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v2.3"
id: "todo"
with:
TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
*.log
*.swp
.tox
.cache
.DS_Store

44
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,44 @@
---
image: "robertdebock/github-action-molecule:4.0.6"
services:
- docker:dind
variables:
DOCKER_HOST: "tcp://docker:2375"
PY_COLORS: 1
molecule:
script:
- image=${image} tag=${tag} molecule test
rules:
- if: $CI_COMMIT_REF_NAME == "master"
retry: 1
parallel:
matrix:
- image: "alpine"
tag: "latest"
- image: "enterpriselinux"
tag: "latest"
- image: "debian"
tag: "latest"
- image: "debian"
tag: "bookworm"
- image: "fedora"
tag: "34"
- image: "fedora"
tag: "latest"
- image: "fedora"
tag: "rawhide"
- image: "opensuse"
tag: "latest"
- image: "ubuntu"
tag: "latest"
- image: "ubuntu"
tag: "bionic"
galaxy:
script:
- ansible-galaxy role import --api-key ${GALAXY_API_KEY} ${CI_PROJECT_NAMESPACE} ${CI_PROJECT_NAME}
rules:
- if: $CI_COMMIT_TAG != null

24
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,24 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/adrienverge/yamllint
rev: v1.26.3
hooks:
- id: yamllint
args: [-c=.yamllint]
- repo: https://github.com/robertdebock/pre-commit
rev: v1.4.4
hooks:
- id: ansible_role_find_unused_variable
- id: ansible_role_find_empty_files
- id: ansible_role_find_empty_directories
- id: ansible_role_fix_readability
- id: ansible_role_find_undefined_handlers
- id: ansible_role_find_unquoted_values

View file

@ -4,40 +4,26 @@
#
language: python
os: linux
dist: xenial
python:
- "3.8"
- "3.9"
services:
- docker
env:
global:
namespace="robertdebock"
matrix:
- image="alpine" tag="latest"
- image="alpine" tag="edge"
- image="centos" tag="7"
- image="centos" tag="latest"
- image="debian" tag="latest"
- image="debian" tag="bullseye"
- image="fedora" tag="31"
- image="fedora" tag="latest"
- image="opensuse" tag="latest"
- image="ubuntu" tag="latest"
- image="ubuntu" tag="bionic"
- image="ubuntu" tag="xenial"
cache:
- pip
install:
- pip install --upgrade pip
- pip install tox
- pip install ansible ansible-lint yamllint
script:
- function retry { counter=0 ; until "$@" ; do exit=$? ; counter=$(($counter + 1)) ; if [ $counter -ge 3 ] ; then return $exit ; fi ; done ; return 0; } ; retry tox --parallel all
- yamllint .
- ansible-lint
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
slack: "BEAf5JsdWsje2YBWtcq0xmdkz1MqCPN0essozaZjUJDSB2LH/DTzdihaakr4peeBdd9Xmus9aiMras8nNRgXHEw1zmm5cc7B95+zlDST82W/oTtA6kXo+mEdvWbQT9VPwZAB+5Vt9PLL3YgRjJ9lmBvGJ84yKm6sRkt5doykr3MGFJSgOtUTADjOh22GZESSXizQQyNOV8fvEEfez5TXEkwigyM1iKMeIkWCWDYHXdSUhAP6PVA+GghObI9/6gcJzieK6NqD7FNKPyOtDQk/y+cNC4xdOEKoCD7/OVmCm0iTkW1qjBkBo94bu08DfZn2Ee9/pAgNN/4PJz7KABAtDmBmSBWiLpvuQ9mzkBKQ08Qa9tyAiJiIgSYyvqjNf0mal3muzAn1cQIuwDSrYq8VklcF8zW0oYrw6GCqvVSe2uf9bAwLNBZylWIucdRYK5oScP8V+v19p0Mp/vz3uYJOeErf5QE7YORDsYGcUBokJmGWIqLtdbAUTq41FMTycqzUIdQLEqUZx0QcfoSPoF50/tQ+cuq9MxIORvc8kzO8v4KYHcE3Ji78M2UY/LhpnI5h+xFjmQ4YsTvOTX6N0+jprFUjhJZjdn7h2DJxinA1cTqoGxyrzvLIJKb5rEQr4uZkstGtx1UjGYMMZprK2MiJkqoJKrSHrF/p/RIxSTmeY0k="
email: false

View file

@ -10,3 +10,7 @@ rules:
level: error
line-length: disable
truthy: disable
ignore: |
.tox/
.cache/

View file

@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2020 Robert de Bock (robert@meinit.nl)
Copyright 2022 Robert de Bock (robert@meinit.nl)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View file

@ -2,13 +2,13 @@
Configure grub on your system.
|Travis|GitHub|Quality|Downloads|Version|
|GitHub|GitLab|Quality|Downloads|Version|
|------|------|-------|---------|-------|
|[![travis](https://travis-ci.com/robertdebock/ansible-role-grub.svg?branch=master)](https://travis-ci.com/robertdebock/ansible-role-grub)|[![github](https://github.com/robertdebock/ansible-role-grub/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-grub/actions)|[![quality](https://img.shields.io/ansible/quality/48762)](https://galaxy.ansible.com/robertdebock/grub)|[![downloads](https://img.shields.io/ansible/role/d/48762)](https://galaxy.ansible.com/robertdebock/grub)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-grub.svg)](https://github.com/robertdebock/ansible-role-grub/releases/)|
|[![github](https://github.com/robertdebock/ansible-role-grub/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-grub/actions)|[![gitlab](https://gitlab.com/robertdebock/ansible-role-grub/badges/master/pipeline.svg)](https://gitlab.com/robertdebock/ansible-role-grub)|[![quality](https://img.shields.io/ansible/quality/48762)](https://galaxy.ansible.com/robertdebock/grub)|[![downloads](https://img.shields.io/ansible/role/d/48762)](https://galaxy.ansible.com/robertdebock/grub)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-grub.svg)](https://github.com/robertdebock/ansible-role-grub/releases/)|
## [Example Playbook](#example-playbook)
This example is taken from `molecule/resources/converge.yml` and is tested on each push, pull request and release.
This example is taken from `molecule/default/converge.yml` and is tested on each push, pull request and release.
```yaml
---
- name: Converge
@ -25,7 +25,7 @@ This example is taken from `molecule/resources/converge.yml` and is tested on ea
value: 0
```
The machine may need to be prepared using `molecule/resources/prepare.yml`:
The machine needs to be prepared. In CI this is done using `molecule/default/prepare.yml`:
```yaml
---
- name: prepare
@ -38,36 +38,23 @@ The machine may need to be prepared using `molecule/resources/prepare.yml`:
tasks:
- name: make /etc/default
file:
ansible.builtin.file:
path: /etc/default
state: directory
mode: "0755"
- name: place bogus /etc/default/grub
copy:
ansible.builtin.copy:
content: 'GRUB_CMDLINE_LINUX="a=1"'
dest: /etc/default/grub
```
For verification `molecule/resources/verify.yml` run after the role has been applied.
```yaml
---
- name: Verify
hosts: all
become: yes
gather_facts: yes
tasks:
- name: check that bogus options are in
command: grep 'a=1' /etc/default/grub
- name: check that selected option is in
command: grep 'cgroup_enable=memory' /etc/default/grub
mode: "0664"
```
Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles.
## [Role Variables](#role-variables)
These variables are set in `defaults/main.yml`:
The default values for the variables are set in `defaults/main.yml`:
```yaml
---
# defaults file for grub
@ -84,23 +71,22 @@ grub_recordfail_timeout: "{{ grub_timeout }}"
## [Requirements](#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.)
- pip packages listed in [requirements.txt](https://github.com/robertdebock/ansible-role-grub/blob/master/requirements.txt).
The following roles can be installed to ensure all requirements are met, using `ansible-galaxy install -r requirements.yml`:
## [Status of used roles](#status-of-requirements)
```yaml
---
- robertdebock.bootstrap
The following roles are used to prepare a system. You can prepare your system in another way.
```
| Requirement | GitHub | GitLab |
|-------------|--------|--------|
|[robertdebock.bootstrap](https://galaxy.ansible.com/robertdebock/bootstrap)|[![Build Status GitHub](https://github.com/robertdebock/ansible-role-bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bootstrap/actions)|[![Build Status GitLab ](https://gitlab.com/robertdebock/ansible-role-bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock/ansible-role-bootstrap)|
## [Context](#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:
![dependencies](https://raw.githubusercontent.com/robertdebock/drawings/artifacts/grub.png "Dependency")
![dependencies](https://raw.githubusercontent.com/robertdebock/ansible-role-grub/png/requirements.png "Dependencies")
## [Compatibility](#compatibility)
@ -109,59 +95,26 @@ This role has been tested on these [container images](https://hub.docker.com/u/r
|container|tags|
|---------|----|
|alpine|all|
|el|7, 8|
|debian|buster, bullseye|
|fedora|31, 32|
|el|8|
|debian|all|
|fedora|all|
|opensuse|all|
|ubuntu|focal, bionic, xenial|
|ubuntu|all|
The minimum version of Ansible required is 2.8 but tests have been done to:
The minimum version of Ansible required is 2.10, tests have been done to:
- The previous version, on version lower.
- The previous version.
- The current version.
- The development version.
## [Testing](#testing)
[Unit tests](https://travis-ci.com/robertdebock/ansible-role-grub) are done on every commit, pull request, release and periodically.
If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-grub/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: `robertdebock`, image: `fedora`, tag: `latest`):
```
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: `robertdebock`, image: `fedora`, tag: `latest`) tests:
```
tox
# To run CentOS (namespace: `robertdebock`, tag: `latest`)
image="centos" tox
# Or customize more:
image="debian" tag="stable" tox
```
## [License](#license)
Apache-2.0
## [Author Information](#author-information)
[Robert de Bock](https://robertdebock.nl/)

View file

@ -1,9 +1,9 @@
---
# defaults file for grub
grub_timeout: 5
#grub_timeout: 5
grub_recordfail_timeout: "{{ grub_timeout }}"
#grub_recordfail_timeout: "{{ grub_timeout }}"
# Add options here, for example:
# grub_options:

View file

@ -1,11 +1,13 @@
---
# handlers file for grub
- name: update grub
command: "{{ grub_update_grub_command }}"
ansible.builtin.command:
cmd: "{{ grub_update_grub_command }}"
when:
- ansible_connection != "docker"
- ansible_connection not in [ "container", "docker", "community.docker.docker" ]
notify:
- reboot
- name: reboot
reboot:
ansible.builtin.reboot:

View file

@ -1,10 +1,12 @@
---
galaxy_info:
author: Robert de Bock
namespace: robertdebock
role_name: grub
description: Configure grub on your system.
license: Apache-2.0
company: none
min_ansible_version: 2.8
min_ansible_version: "2.10"
platforms:
- name: Alpine
@ -12,28 +14,21 @@ galaxy_info:
- all
- name: EL
versions:
- 7
- 8
- name: Debian
versions:
- buster
- bullseye
- all
- name: Fedora
versions:
- 31
- 32
- all
- name: OpenSUSE
versions:
- all
- name: Ubuntu
versions:
- focal
- bionic
- xenial
- all
galaxy_tags:
- grub
- centos
- redhat
dependencies: []

View file

@ -6,10 +6,11 @@ dependency:
name: galaxy
options:
role-file: requirements.yml
requirements-file: requirements.yml
lint: |
PATH=${PATH}
yamllint molecule/default/converge.yml
ansible-lint molecule/default/converge.yml
set -e
yamllint .
ansible-lint
driver:
name: docker
platforms:
@ -22,9 +23,5 @@ platforms:
pre_build_image: yes
provisioner:
name: ansible
config_options:
defaults:
stdout_callback: yaml
bin_ansible_callbacks: yes
verifier:
name: ansible

View file

@ -9,10 +9,13 @@
tasks:
- name: make /etc/default
file:
ansible.builtin.file:
path: /etc/default
state: directory
mode: "0755"
- name: place bogus /etc/default/grub
copy:
ansible.builtin.copy:
content: 'GRUB_CMDLINE_LINUX="a=1"'
dest: /etc/default/grub
mode: "0664"

View file

@ -2,11 +2,13 @@
- name: Verify
hosts: all
become: yes
gather_facts: yes
gather_facts: no
tasks:
- name: check that bogus options are in
command: grep 'a=1' /etc/default/grub
ansible.builtin.command:
cmd: grep 'a=1' /etc/default/grub
- name: check that selected option is in
command: grep 'cgroup_enable=memory' /etc/default/grub
ansible.builtin.command:
cmd: grep 'cgroup_enable=memory' /etc/default/grub

10
requirements.txt Normal file
View file

@ -0,0 +1,10 @@
# These role have been tested with these PIP component.
# To install the required version yourself, use a command as:
# `python -m pip --user install -r requirements.txt`
# See the pip requirements file documentation for details:
# https://pip.pypa.io/en/stable/user_guide/#requirements-files
#
# Tests run on the previous and current (latest) version of Ansible.
ansible>=2.10
# Some Jinja2 filters are used that are available in the newer releases.
jinja2>=2.11.2

View file

@ -1,2 +1,4 @@
---
- robertdebock.bootstrap
roles:
- name: robertdebock.bootstrap
collections:

View file

@ -1,33 +1,34 @@
---
- name: test if grub_timeout is set correctly
assert:
ansible.builtin.assert:
that:
- grub_timeout is defined
- grub_timeout | int >= 0
- grub_timeout is number
- grub_timeout >= 0
quiet: yes
when: grub_timeout is defined
- name: test if grub_recordfail_timeout is set correctly
assert:
ansible.builtin.assert:
that:
- grub_recordfail_timeout is defined
- grub_recordfail_timeout | int >= 0
- grub_recordfail_timeout is number
- grub_recordfail_timeout >= 0
quiet: yes
when: grub_timeout is defined and grub_recordfail_timeout is defined
- name: test if grub_options is set correctly
assert:
ansible.builtin.assert:
that:
- grub_options | length > 0
- grub_options is iterable
quiet: yes
when:
- grub_options is defined
- name: test if item in grub_options is set correctly
assert:
ansible.builtin.assert:
that:
- item.option is defined
- item.option | length > 0
- item.value is defined
- item.option is string
quiet: yes
loop: "{{ grub_options }}"
loop_control:

View file

@ -1,36 +1,41 @@
---
# tasks file for grub
- name: include assert.yml
include_tasks: assert.yml
- name: import assert.yml
ansible.builtin.import_tasks: assert.yml
run_once: yes
delegate_to: localhost
- name: install required packages
package:
ansible.builtin.package:
name: "{{ grub_packages }}"
state: present
- name: set GRUB_TIMEOUT
lineinfile:
ansible.builtin.lineinfile:
path: /etc/default/grub
line: GRUB_TIMEOUT={{ grub_timeout }}
create: yes
mode: "0664"
when: grub_timeout is defined
notify:
- update grub
- name: set GRUB_RECORDFAIL_TIMEOUT
lineinfile:
ansible.builtin.lineinfile:
path: /etc/default/grub
line: GRUB_RECORDFAIL_TIMEOUT={{ grub_recordfail_timeout }}
create: yes
mode: "0664"
when: grub_recordfail_timeout is defined
notify:
- update grub
- name: add options to GRUB_CMDLINE_LINUX
replace:
ansible.builtin.replace:
path: /etc/default/grub
regexp: '^GRUB_CMDLINE_LINUX="((:?(?!{{ item.option }}={{ item.value }}).)*?)"$'
replace: 'GRUB_CMDLINE_LINUX="\1 {{ item.option }}={{ item.value }}"'
regexp: '^GRUB_CMDLINE_LINUX="((:?(?!{{ item.option }}{{ "={}".format(item.value) if item.value is defined else "" }}).)*?)"$'
replace: 'GRUB_CMDLINE_LINUX="\1 {{ item.option }}{{ "={}".format(item.value) if item.value is defined else "" }}"'
validate: /bin/sh %s
mode: "0664"
loop: "{{ grub_options }}"
@ -42,5 +47,22 @@
- grub_options is defined
- grub_options | length > 0
- name: add options to GRUB_CMDLINE_LINUX_DEFAULT
ansible.builtin.replace:
path: /etc/default/grub
regexp: '^GRUB_CMDLINE_LINUX_DEFAULT="((:?(?!{{ item.option }}=?[^s]*).)*?)"$'
replace: 'GRUB_CMDLINE_LINUX_DEFAULT="\1 {{ item.option }}{{ "={}".format(item.value) if item.value is defined else "" }}"'
validate: /bin/sh %s
mode: "0664"
loop: "{{ grub_default_options }}"
loop_control:
label: "{{ item.option }}"
notify:
- update grub
when:
- grub_default_options is defined
- grub_default_options | length > 0
- name: flush handlers
meta: flush_handlers
ansible.builtin.meta: flush_handlers

22
tox.ini
View file

@ -2,25 +2,23 @@
# Ansible managed
#
[tox]
minversion = 3.7
# Disabled "next" because of:
# https://github.com/ansible-community/molecule/issues/2626.
# envlist = py{38}-ansible-{previous,current,next}
envlist = py{38}-ansible-{previous,current}
minversion = 3.21.4
envlist = py{310}-ansible-{4,5}
skipsdist = true
[testenv]
deps =
previous: ansible>=2.8, <2.9
current: ansible>=2.9
next: git+https://github.com/ansible/ansible.git@devel
molecule[lint]>=3, <4
docker>=4.2, <4.3
4: ansible == 4.*
5: ansible == 5.*
molecule[docker]
docker == 5.*
ansible-lint == 5.*
commands = molecule test
setenv =
TOX_ENVNAME={envname}
MOLECULE_EPHEMERAL_DIRECTORY=/tmp/.molecule/{env:image:fedora}-{env:tag:latest}/{envname}
PY_COLORS=1
ANSIBLE_FORCE_COLOR=1
ANSIBLE_ROLES_PATH=../
passenv = namespace image tag
passenv = namespace image tag DOCKER_HOST

View file

@ -9,11 +9,11 @@ _grub_packages:
Debian:
- grub2
grub_packages: "{{ _grub_packages[ansible_os_family] | default(_grub_packages['default']) }}"
grub_packages: "{{ _grub_packages[ansible_os_family] | default(_grub_packages['default'] ) }}"
_grub_update_grub_command:
default: grub2-mkconfig -o /boot/grub2/grub.cfg
Alpine: grub-mkconfig -o /boot/grub/grub.cfg
Debian: update-grub
grub_update_grub_command: "{{ _grub_update_grub_command[ansible_os_family] | default(_grub_update_grub_command['default']) }}"
grub_update_grub_command: "{{ _grub_update_grub_command[ansible_os_family] | default(_grub_update_grub_command['default'] ) }}"