Rolle aktualisiert: bootstrap (#457)
Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: #457
This commit is contained in:
parent
3cc377c1a7
commit
686a0b281f
25 changed files with 201 additions and 210 deletions
|
@ -1,8 +1,14 @@
|
||||||
|
---
|
||||||
#
|
#
|
||||||
# Ansible managed
|
# Ansible managed
|
||||||
#
|
#
|
||||||
exclude_paths:
|
exclude_paths:
|
||||||
- ./meta/exception.yml
|
|
||||||
- ./meta/preferences.yml
|
- ./meta/preferences.yml
|
||||||
|
- ./molecule/default/prepare.yml
|
||||||
|
- ./molecule/default/converge.yml
|
||||||
- ./molecule/default/verify.yml
|
- ./molecule/default/verify.yml
|
||||||
|
- ./molecule/default/collections.yml
|
||||||
- ./.tox
|
- ./.tox
|
||||||
|
- ./.cache
|
||||||
|
- ./.github
|
||||||
|
- ./requirements.yml
|
||||||
|
|
|
@ -5,6 +5,7 @@ about: Create a report to help me improve
|
||||||
---
|
---
|
||||||
|
|
||||||
## Describe the bug
|
## Describe the bug
|
||||||
|
|
||||||
A clear and concise description of what the bug is.
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
## Playbook
|
## Playbook
|
||||||
|
|
|
@ -13,6 +13,6 @@ jobs:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: galaxy
|
- name: galaxy
|
||||||
uses: robertdebock/galaxy-action@1.1.0
|
uses: robertdebock/galaxy-action@1.2.0
|
||||||
with:
|
with:
|
||||||
galaxy_api_key: ${{ secrets.galaxy_api_key }}
|
galaxy_api_key: ${{ secrets.galaxy_api_key }}
|
||||||
|
|
|
@ -11,20 +11,16 @@ on:
|
||||||
- '*'
|
- '*'
|
||||||
pull_request:
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '2 2 2 * *'
|
- cron: '3 2 2 * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
- name: ansible-lint
|
||||||
path: "${{ github.repository }}"
|
uses: ansible-community/ansible-lint-action@main
|
||||||
- name: molecule
|
|
||||||
uses: robertdebock/molecule-action@2.6.8
|
|
||||||
with:
|
|
||||||
command: lint
|
|
||||||
test:
|
test:
|
||||||
needs:
|
needs:
|
||||||
- lint
|
- lint
|
||||||
|
@ -33,18 +29,22 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config:
|
||||||
|
- image: "alpine"
|
||||||
|
tag: "latest"
|
||||||
- image: "amazonlinux"
|
- image: "amazonlinux"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "centos"
|
- image: "enterpriselinux"
|
||||||
tag: "7"
|
tag: "7"
|
||||||
- image: "centos"
|
- image: "enterpriselinux"
|
||||||
|
tag: "8"
|
||||||
|
- image: "enterpriselinux"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "debian"
|
- image: "debian"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "debian"
|
- image: "debian"
|
||||||
tag: "bullseye"
|
tag: "bookworm"
|
||||||
- image: "fedora"
|
- image: "fedora"
|
||||||
tag: "32"
|
tag: "36"
|
||||||
- image: "fedora"
|
- image: "fedora"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "fedora"
|
- image: "fedora"
|
||||||
|
@ -53,11 +53,13 @@ jobs:
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "ubuntu"
|
- image: "ubuntu"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
|
- image: "ubuntu"
|
||||||
|
tag: "focal"
|
||||||
- image: "ubuntu"
|
- image: "ubuntu"
|
||||||
tag: "bionic"
|
tag: "bionic"
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: "${{ github.repository }}"
|
path: "${{ github.repository }}"
|
||||||
- name: disable apparmor for mysql
|
- name: disable apparmor for mysql
|
||||||
|
@ -65,7 +67,7 @@ jobs:
|
||||||
- name: parse apparmor for mysql
|
- name: parse apparmor for mysql
|
||||||
run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
|
run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
|
||||||
- name: molecule
|
- name: molecule
|
||||||
uses: robertdebock/molecule-action@2.6.8
|
uses: robertdebock/molecule-action@5.0.0
|
||||||
with:
|
with:
|
||||||
image: ${{ matrix.config.image }}
|
image: ${{ matrix.config.image }}
|
||||||
tag: ${{ matrix.config.tag }}
|
tag: ${{ matrix.config.tag }}
|
||||||
|
|
|
@ -13,7 +13,7 @@ jobs:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ github.repository }}
|
path: ${{ github.repository }}
|
||||||
- name: create png
|
- name: create png
|
||||||
|
|
2
roles/robertdebock.bootstrap/.gitignore
vendored
2
roles/robertdebock.bootstrap/.gitignore
vendored
|
@ -2,3 +2,5 @@
|
||||||
*.log
|
*.log
|
||||||
*.swp
|
*.swp
|
||||||
.tox
|
.tox
|
||||||
|
.cache
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
---
|
---
|
||||||
image: robertdebock/github-action-molecule:2.6.6
|
image: "robertdebock/github-action-molecule:5.0.0"
|
||||||
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
DOCKER_HOST: "tcp://docker:2375"
|
|
||||||
PY_COLORS: 1
|
PY_COLORS: 1
|
||||||
|
|
||||||
molecule:
|
molecule:
|
||||||
script:
|
script:
|
||||||
- image=${image} tag=${tag} molecule test
|
- if [ -f tox.ini ] ; then tox ; fi
|
||||||
|
- if [ ! -f tox.ini ] ; then molecule test ; fi
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_REF_NAME == "master"
|
- if: $CI_COMMIT_REF_NAME == "master"
|
||||||
retry: 2
|
|
||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
|
- image: "alpine"
|
||||||
|
tag: "latest"
|
||||||
- image: "amazonlinux"
|
- image: "amazonlinux"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "centos"
|
- image: "enterpriselinux"
|
||||||
tag: "7"
|
tag: "7"
|
||||||
- image: "centos"
|
- image: "enterpriselinux"
|
||||||
|
tag: "8"
|
||||||
|
- image: "enterpriselinux"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "debian"
|
- image: "debian"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "debian"
|
- image: "debian"
|
||||||
tag: "bullseye"
|
tag: "bookworm"
|
||||||
- image: "fedora"
|
- image: "fedora"
|
||||||
tag: "32"
|
tag: "36"
|
||||||
- image: "fedora"
|
- image: "fedora"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "fedora"
|
- image: "fedora"
|
||||||
|
@ -36,11 +36,13 @@ molecule:
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
- image: "ubuntu"
|
- image: "ubuntu"
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
|
- image: "ubuntu"
|
||||||
|
tag: "focal"
|
||||||
- image: "ubuntu"
|
- image: "ubuntu"
|
||||||
tag: "bionic"
|
tag: "bionic"
|
||||||
|
|
||||||
galaxy:
|
galaxy:
|
||||||
script:
|
script:
|
||||||
- ansible-galaxy role import --api-key ${GALAXY_API_KEY} ${CI_PROJECT_NAMESPACE} ${CI_PROJECT_NAME}
|
- ansible-galaxy role import --api-key ${GALAXY_API_KEY} robertdebock ${CI_PROJECT_NAME}
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_TAG != null
|
- if: $CI_COMMIT_TAG != null
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
---
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.4.0
|
rev: v4.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
|
|
||||||
- repo: https://github.com/adrienverge/yamllint
|
- repo: https://github.com/adrienverge/yamllint
|
||||||
rev: v1.25.0
|
rev: v1.26.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
args: [-c=.yamllint]
|
args: [-c=.yamllint]
|
||||||
|
|
||||||
- repo: https://github.com/ansible/ansible-lint
|
|
||||||
rev: v4.3.7
|
|
||||||
hooks:
|
|
||||||
- id: ansible-lint
|
|
||||||
pass_filenames: false
|
|
||||||
|
|
||||||
- repo: https://github.com/robertdebock/pre-commit
|
- repo: https://github.com/robertdebock/pre-commit
|
||||||
rev: v1.1.2
|
rev: v1.5.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: ansible_role_find_unused_variable
|
- id: ansible_role_find_unused_variable
|
||||||
- id: ansible_role_find_empty_files
|
- id: ansible_role_find_empty_files
|
||||||
|
- id: ansible_role_find_empty_directories
|
||||||
|
- id: ansible_role_find_undefined_handlers
|
||||||
|
- id: ansible_role_find_unquoted_values
|
||||||
|
- id: ansible_role_find_horizontal_when
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
---
|
|
||||||
#
|
|
||||||
# Ansible managed
|
|
||||||
#
|
|
||||||
language: python
|
|
||||||
|
|
||||||
os: linux
|
|
||||||
dist: xenial
|
|
||||||
|
|
||||||
python:
|
|
||||||
- "3.9"
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
cache:
|
|
||||||
- pip
|
|
||||||
|
|
||||||
install:
|
|
||||||
- pip install --upgrade pip
|
|
||||||
- pip install yamllint
|
|
||||||
- pip install ansible-lint
|
|
||||||
|
|
||||||
script:
|
|
||||||
- yamllint .
|
|
||||||
- ansible-lint
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
|
||||||
email: false
|
|
|
@ -13,3 +13,4 @@ rules:
|
||||||
|
|
||||||
ignore: |
|
ignore: |
|
||||||
.tox/
|
.tox/
|
||||||
|
.cache/
|
||||||
|
|
|
@ -187,7 +187,7 @@
|
||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2021 Robert de Bock (robert@meinit.nl)
|
Copyright 2023 Robert de Bock (robert@meinit.nl)
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -4,16 +4,24 @@ Prepare your system to be managed by Ansible.
|
||||||
|
|
||||||
|GitHub|GitLab|Quality|Downloads|Version|
|
|GitHub|GitLab|Quality|Downloads|Version|
|
||||||
|------|------|-------|---------|-------|
|
|------|------|-------|---------|-------|
|
||||||
|[![github](https://github.com/robertdebock/ansible-role-bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bootstrap/actions)|[![gitlab](https://gitlab.com/robertdebock/ansible-role-bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock/ansible-role-bootstrap)|[![quality](https://img.shields.io/ansible/quality/21642)](https://galaxy.ansible.com/robertdebock/bootstrap)|[![downloads](https://img.shields.io/ansible/role/d/21642)](https://galaxy.ansible.com/robertdebock/bootstrap)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-bootstrap.svg)](https://github.com/robertdebock/ansible-role-bootstrap/releases/)|
|
|[![github](https://github.com/robertdebock/ansible-role-bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bootstrap/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap)|[![quality](https://img.shields.io/ansible/quality/21642)](https://galaxy.ansible.com/robertdebock/bootstrap)|[![downloads](https://img.shields.io/ansible/role/d/21642)](https://galaxy.ansible.com/robertdebock/bootstrap)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-bootstrap.svg)](https://github.com/robertdebock/ansible-role-bootstrap/releases/)|
|
||||||
|
|
||||||
## [Example Playbook](#example-playbook)
|
## [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`](https://github.com/robertdebock/ansible-role-bootstrap/blob/master/molecule/default/converge.yml) and is tested on each push, pull request and release.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
- name: Converge
|
- name: Converge
|
||||||
hosts: all
|
hosts: all
|
||||||
become: yes
|
# This role installs packages using the `raw` module and needs to connect as
|
||||||
|
# `root`. (`sudo` is not available before bootstrapping.) All tasks in the
|
||||||
|
# role have `become` set to `no`, so you can use either `no` or `yes` for
|
||||||
|
# `become`, the role will not use become (so `sudo`) for any task.
|
||||||
|
become: yes # `no` will also work.
|
||||||
|
# This role installs python, gathering facts can't be done before `python` is
|
||||||
|
# installed. This role runs the `setup` module, so facts will be available
|
||||||
|
# after running the role.
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
|
@ -24,19 +32,20 @@ Also see a [full explanation and example](https://robertdebock.nl/how-to-use-the
|
||||||
|
|
||||||
## [Role Variables](#role-variables)
|
## [Role Variables](#role-variables)
|
||||||
|
|
||||||
These variables are set in `defaults/main.yml`:
|
The default values for the variables are set in [`defaults/main.yml`](https://github.com/robertdebock/ansible-role-bootstrap/blob/master/defaults/main.yml):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
# defaults file for bootstrap
|
# defaults file for bootstrap
|
||||||
|
|
||||||
# The user to use to connect to machines.
|
|
||||||
bootstrap_user: root
|
|
||||||
|
|
||||||
# Do you want to wait for the host to be available?
|
# Do you want to wait for the host to be available?
|
||||||
bootstrap_wait_for_host: no
|
bootstrap_wait_for_host: no
|
||||||
|
|
||||||
# The number of seconds you want to wait during connection test before failing.
|
# The number of seconds you want to wait during connection test before failing.
|
||||||
bootstrap_timeout: 3
|
bootstrap_timeout: 3
|
||||||
|
|
||||||
|
# Tell the role to "become" or not.
|
||||||
|
bootstrap_become: yes
|
||||||
```
|
```
|
||||||
|
|
||||||
## [Requirements](#requirements)
|
## [Requirements](#requirements)
|
||||||
|
@ -57,12 +66,13 @@ This role has been tested on these [container images](https://hub.docker.com/u/r
|
||||||
|
|
||||||
|container|tags|
|
|container|tags|
|
||||||
|---------|----|
|
|---------|----|
|
||||||
|amazon|Candidate|
|
|[Alpine](https://hub.docker.com/repository/docker/robertdebock/alpine/general)|all|
|
||||||
|el|7, 8|
|
|[Amazon](https://hub.docker.com/repository/docker/robertdebock/amazonlinux/general)|Candidate|
|
||||||
|debian|all|
|
|[EL](https://hub.docker.com/repository/docker/robertdebock/enterpriselinux/general)|all|
|
||||||
|fedora|all|
|
|[Debian](https://hub.docker.com/repository/docker/robertdebock/debian/general)|all|
|
||||||
|opensuse|all|
|
|[Fedora](https://hub.docker.com/repository/docker/robertdebock/fedora/general)|all|
|
||||||
|ubuntu|focal, bionic|
|
|[opensuse](https://hub.docker.com/repository/docker/robertdebock/opensuse/general)|all|
|
||||||
|
|[Ubuntu](https://hub.docker.com/repository/docker/robertdebock/ubuntu/general)|all|
|
||||||
|
|
||||||
The minimum version of Ansible required is 2.10, tests have been done to:
|
The minimum version of Ansible required is 2.10, tests have been done to:
|
||||||
|
|
||||||
|
@ -70,34 +80,14 @@ The minimum version of Ansible required is 2.10, tests have been done to:
|
||||||
- The current version.
|
- The current version.
|
||||||
- The development version.
|
- The development version.
|
||||||
|
|
||||||
## [Exceptions](#exceptions)
|
|
||||||
|
|
||||||
Some variarations of the build matrix do not work. These are the variations and reasons why the build won't work:
|
|
||||||
|
|
||||||
| variation | reason |
|
|
||||||
|---------------------------|------------------------|
|
|
||||||
| alpine:edge | Failed to create temporary directory. |
|
|
||||||
|
|
||||||
|
|
||||||
If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-bootstrap/issues)
|
If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-bootstrap/issues)
|
||||||
|
|
||||||
## [License](#license)
|
## [License](#license)
|
||||||
|
|
||||||
Apache-2.0
|
[Apache-2.0](https://github.com/robertdebock/ansible-role-bootstrap/blob/master/LICENSE).
|
||||||
|
|
||||||
## [Contributors](#contributors)
|
|
||||||
|
|
||||||
I'd like to thank everybody that made contributions to this repository. It motivates me, improves the code and is just fun to collaborate.
|
|
||||||
|
|
||||||
- [rembik](https://github.com/rembik)
|
|
||||||
- [jellevandehaterd](https://github.com/jellevandehaterd)
|
|
||||||
- [fzarifian](https://github.com/fzarifian)
|
|
||||||
- [kmonticolo](https://github.com/kmonticolo)
|
|
||||||
- [CrystalStiletto](https://github.com/CrystalStiletto)
|
|
||||||
- [infothrill](https://github.com/infothrill)
|
|
||||||
|
|
||||||
## [Author Information](#author-information)
|
## [Author Information](#author-information)
|
||||||
|
|
||||||
[Robert de Bock](https://robertdebock.nl/)
|
[robertdebock](https://robertdebock.nl/)
|
||||||
|
|
||||||
Please consider [sponsoring me](https://github.com/sponsors/robertdebock).
|
Please consider [sponsoring me](https://github.com/sponsors/robertdebock).
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
# defaults file for bootstrap
|
# defaults file for bootstrap
|
||||||
|
|
||||||
# The user to use to connect to machines.
|
|
||||||
bootstrap_user: root
|
|
||||||
|
|
||||||
# Do you want to wait for the host to be available?
|
# Do you want to wait for the host to be available?
|
||||||
bootstrap_wait_for_host: no
|
bootstrap_wait_for_host: no
|
||||||
|
|
||||||
# The number of seconds you want to wait during connection test before failing.
|
# The number of seconds you want to wait during connection test before failing.
|
||||||
bootstrap_timeout: 3
|
bootstrap_timeout: 3
|
||||||
|
|
||||||
|
# Tell the role to "become" or not.
|
||||||
|
bootstrap_become: yes
|
||||||
|
|
18
roles/robertdebock.bootstrap/meta/argument_specs.yml
Normal file
18
roles/robertdebock.bootstrap/meta/argument_specs.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
short_description: "Prepare a system to be managed by Ansible."
|
||||||
|
description: >
|
||||||
|
Install the minimum required set of packages (python and sudo) to allow Ansible to manage a system.
|
||||||
|
This role tries to figure out what to install and uses the raw module to install the packages.
|
||||||
|
author: Robert de Bock
|
||||||
|
options:
|
||||||
|
bootstrap_wait_for_host:
|
||||||
|
type: "bool"
|
||||||
|
default: no
|
||||||
|
description: "Wait for the machine to be available."
|
||||||
|
bootstrap_timeout:
|
||||||
|
type: "int"
|
||||||
|
default: 3
|
||||||
|
description: "Time (in seconds) to wait for connection."
|
|
@ -1,4 +0,0 @@
|
||||||
---
|
|
||||||
exceptions:
|
|
||||||
- variation: alpine:edge
|
|
||||||
reason: "Failed to create temporary directory."
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Robert de Bock
|
author: robertdebock
|
||||||
role_name: bootstrap
|
role_name: bootstrap
|
||||||
description: Prepare your system to be managed by Ansible.
|
description: Prepare your system to be managed by Ansible.
|
||||||
license: Apache-2.0
|
license: Apache-2.0
|
||||||
|
@ -8,30 +8,27 @@ galaxy_info:
|
||||||
min_ansible_version: "2.10"
|
min_ansible_version: "2.10"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
# Broken: idempotence, gather_facts: Failed to create temporary directory.
|
- name: Alpine
|
||||||
# - name: Alpine
|
versions:
|
||||||
# versions:
|
- all
|
||||||
# - all
|
|
||||||
- name: Amazon
|
- name: Amazon
|
||||||
versions:
|
versions:
|
||||||
- Candidate
|
- Candidate
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
- 7
|
- all
|
||||||
- 8
|
|
||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- all
|
- all
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
versions:
|
versions:
|
||||||
- all
|
- all
|
||||||
- name: OpenSUSE
|
- name: opensuse
|
||||||
versions:
|
versions:
|
||||||
- all
|
- all
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- focal
|
- all
|
||||||
- bionic
|
|
||||||
|
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- bootstrap
|
- bootstrap
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
---
|
---
|
||||||
- name: Converge
|
- name: Converge
|
||||||
hosts: all
|
hosts: all
|
||||||
become: yes
|
# This role installs packages using the `raw` module and needs to connect as
|
||||||
|
# `root`. (`sudo` is not available before bootstrapping.) All tasks in the
|
||||||
|
# role have `become` set to `no`, so you can use either `no` or `yes` for
|
||||||
|
# `become`, the role will not use become (so `sudo`) for any task.
|
||||||
|
become: yes # `no` will also work.
|
||||||
|
# This role installs python, gathering facts can't be done before `python` is
|
||||||
|
# installed. This role runs the `setup` module, so facts will be available
|
||||||
|
# after running the role.
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
|
|
|
@ -6,6 +6,7 @@ dependency:
|
||||||
name: galaxy
|
name: galaxy
|
||||||
options:
|
options:
|
||||||
role-file: requirements.yml
|
role-file: requirements.yml
|
||||||
|
requirements-file: requirements.yml
|
||||||
lint: |
|
lint: |
|
||||||
set -e
|
set -e
|
||||||
yamllint .
|
yamllint .
|
||||||
|
@ -22,9 +23,5 @@ platforms:
|
||||||
pre_build_image: yes
|
pre_build_image: yes
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
config_options:
|
|
||||||
defaults:
|
|
||||||
stdout_callback: yaml
|
|
||||||
bin_ansible_callbacks: yes
|
|
||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: test connection
|
- name: test connection
|
||||||
ping:
|
ansible.builtin.ping:
|
||||||
|
|
||||||
- name: try the package module
|
- name: try the package module
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: gzip
|
name: gzip
|
||||||
state: present
|
state: present
|
||||||
|
|
2
roles/robertdebock.bootstrap/requirements.yml
Normal file
2
roles/robertdebock.bootstrap/requirements.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
collections:
|
|
@ -1,23 +1,23 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: test if bootstrap_user is set correctly
|
- name: Test if bootstrap_wait_for_host is set correctly
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
|
||||||
- bootstrap_user is defined
|
|
||||||
- bootstrap_user is string
|
|
||||||
quiet: yes
|
|
||||||
|
|
||||||
- name: test if bootstrap_wait_for_host is set correctly
|
|
||||||
assert:
|
|
||||||
that:
|
that:
|
||||||
- bootstrap_wait_for_host is defined
|
- bootstrap_wait_for_host is defined
|
||||||
- bootstrap_wait_for_host is boolean
|
- bootstrap_wait_for_host is boolean
|
||||||
quiet: yes
|
quiet: yes
|
||||||
|
|
||||||
- name: test if bootstrap_timeout is set correctly
|
- name: Test if bootstrap_timeout is set correctly
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- bootstrap_timeout is defined
|
- bootstrap_timeout is defined
|
||||||
- bootstrap_timeout is number
|
- bootstrap_timeout is number
|
||||||
- bootstrap_timeout >= 0
|
- bootstrap_timeout >= 0
|
||||||
quiet: yes
|
quiet: yes
|
||||||
|
|
||||||
|
- name: Test if bootstrap_become is set correctly
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- bootstrap_become is defined
|
||||||
|
- bootstrap_become is boolean
|
||||||
|
quiet: yes
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
---
|
---
|
||||||
- name: lookup bootstrap facts
|
|
||||||
|
- name: Lookup bootstrap facts
|
||||||
|
ansible.builtin.raw: "cat /etc/os-release"
|
||||||
become: no
|
become: no
|
||||||
raw: "cat /etc/os-release"
|
|
||||||
check_mode: no
|
check_mode: no
|
||||||
register: bootstrap_facts
|
register: bootstrap_facts
|
||||||
changed_when: no
|
changed_when: no
|
||||||
vars:
|
|
||||||
ansible_user: "{{ bootstrap_user }}"
|
|
||||||
|
|
||||||
- name: set bootstrap facts (I)
|
- name: Set bootstrap facts (I)
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
bootstrap_distribution: "{{ item }}"
|
bootstrap_distribution: "{{ item }}"
|
||||||
bootstrap_distribution_major_version: "{{ bootstrap_facts.stdout_lines | join(',') | regex_replace(
|
bootstrap_distribution_major_version: "{{ bootstrap_facts.stdout_lines | join(',') | regex_replace('^.*VERSION_ID=\"(\\d{1,2})(\\.\\d{1,4})*?\".*$', '\\1') | default('NA') }}"
|
||||||
'^.*VERSION_ID=\"(\\d{1,2})(\\.\\d{1,4})*?\".*$','\\1') | default('NA') }}"
|
|
||||||
loop: "{{ bootstrap_os_family_map | dict2items | map(attribute='value') | flatten }}"
|
loop: "{{ bootstrap_os_family_map | dict2items | map(attribute='value') | flatten }}"
|
||||||
when:
|
when:
|
||||||
- bootstrap_facts.rc == 0
|
- bootstrap_facts.rc == 0
|
||||||
- bootstrap_distribution is not defined
|
- bootstrap_distribution is not defined
|
||||||
- bootstrap_facts.stdout is regex('PRETTY_NAME=.'~ bootstrap_search[item] | default(item) ~'.*')
|
- bootstrap_facts.stdout is regex('PRETTY_NAME=.'~ bootstrap_search[item] | default(item) ~'.*')
|
||||||
|
become: no
|
||||||
|
|
||||||
- name: set bootstrap facts (II)
|
- name: Set bootstrap facts (II)
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
bootstrap_os_family: "{{ item.key }}"
|
bootstrap_os_family: "{{ item.key }}"
|
||||||
loop: "{{ bootstrap_os_family_map | dict2items }}"
|
loop: "{{ bootstrap_os_family_map | dict2items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.key }}"
|
label: "{{ item.key }}"
|
||||||
when:
|
when:
|
||||||
- bootstrap_distribution in item.value
|
- bootstrap_distribution in item.value
|
||||||
|
become: no
|
||||||
|
|
|
@ -1,58 +1,55 @@
|
||||||
---
|
---
|
||||||
# tasks file for bootstrap
|
# tasks file for bootstrap
|
||||||
|
|
||||||
- name: include assert.yml
|
- name: Import assert.yml
|
||||||
import_tasks: assert.yml
|
ansible.builtin.import_tasks: assert.yml
|
||||||
run_once: yes
|
run_once: yes
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: wait for host
|
- name: Wait for port to be available
|
||||||
wait_for:
|
ansible.builtin.wait_for:
|
||||||
port: "{{ ansible_port | default('22') }}"
|
port: "{{ ansible_port | default('22') }}"
|
||||||
host: "{{ (ansible_ssh_host | default(ansible_host) | default(inventory_hostname)) }}"
|
timeout: "{{ bootstrap_timeout }}"
|
||||||
connection: local
|
|
||||||
become: no
|
become: no
|
||||||
when:
|
when:
|
||||||
- ansible_connection is defined
|
- ansible_connection is defined
|
||||||
- ansible_connection not in [ "docker", "container" ]
|
- ansible_connection not in [ "container", "docker", "community.docker.docker" ]
|
||||||
- bootstrap_wait_for_host | bool
|
- bootstrap_wait_for_host | bool
|
||||||
|
|
||||||
- name: prepare system
|
- name: Prepare system
|
||||||
|
# At this stage, python and/or sudo are not installed, `become` can't be used.
|
||||||
|
become: no
|
||||||
block:
|
block:
|
||||||
- name: test connection
|
- name: Test connection
|
||||||
wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
timeout: "{{ bootstrap_timeout }}"
|
timeout: "{{ bootstrap_timeout }}"
|
||||||
register: bootstrap_connect
|
register: bootstrap_connect
|
||||||
changed_when: no
|
changed_when: no
|
||||||
|
- name: Test sudo
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: sudo --version
|
||||||
|
changed_when: no
|
||||||
rescue:
|
rescue:
|
||||||
- name: gather bootstrap facts
|
- name: Gather bootstrap facts
|
||||||
include_tasks: "gather_facts.yml"
|
ansible.builtin.include_tasks:
|
||||||
|
file: gather_facts.yml
|
||||||
|
|
||||||
- name: install bootstrap packages
|
- name: Install bootstrap packages (raw)
|
||||||
raw: "{{ bootstrap_install.raw }}"
|
ansible.builtin.raw: "{{ bootstrap_install.raw }}"
|
||||||
register: bootstrap_install_packages
|
register: bootstrap_install_packages
|
||||||
changed_when:
|
changed_when:
|
||||||
- (bootstrap_install.stdout_regex in bootstrap_install_packages.stdout and
|
- (bootstrap_install.stdout_regex in bootstrap_install_packages.stdout and
|
||||||
bootstrap_os_family in [ "Alpine", "Archlinux", "Gentoo" ]) or
|
bootstrap_os_family in [ "Alpine", "Archlinux", "Gentoo" ]) or
|
||||||
(bootstrap_install.stdout_regex not in bootstrap_install_packages.stdout and
|
(bootstrap_install.stdout_regex not in bootstrap_install_packages.stdout and
|
||||||
bootstrap_os_family in [ "Debian", "RedHat", "Suse" ])
|
bootstrap_os_family in [ "Debian", "RedHat", "Rocky", "Suse" ])
|
||||||
vars:
|
|
||||||
ansible_user: "{{ bootstrap_user }}"
|
|
||||||
always:
|
|
||||||
- name: set bootstrap_ansible_user
|
|
||||||
set_fact:
|
|
||||||
bootstrap_ansible_user: "{{ ansible_user | default(omit) if bootstrap_connect is succeeded else bootstrap_user }}"
|
|
||||||
changed_when: no
|
|
||||||
|
|
||||||
- name: ensure system is prepared
|
- name: Gather ansible facts
|
||||||
block:
|
ansible.builtin.setup:
|
||||||
- name: gather ansible facts
|
become: no
|
||||||
setup:
|
|
||||||
|
|
||||||
- name: install bootstrap packages
|
- name: Install bootstrap packages (package)
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ bootstrap_facts_packages.split() }}"
|
loop: "{{ bootstrap_facts_packages.split() }}"
|
||||||
vars:
|
become: "{{ bootstrap_become }}"
|
||||||
ansible_user: "{{ bootstrap_ansible_user | default(omit) }}"
|
|
||||||
|
|
|
@ -2,25 +2,28 @@
|
||||||
# Ansible managed
|
# Ansible managed
|
||||||
#
|
#
|
||||||
[tox]
|
[tox]
|
||||||
minversion = 3.20
|
minversion = 4.2.4
|
||||||
# These environments are disabled:
|
envlist = py{310}-ansible{5,6,7}
|
||||||
# previous: Because collections don't work. ETA Fix: ansible-2.11 released.
|
|
||||||
envlist = py{39}-ansible-{current,next}
|
|
||||||
|
|
||||||
skipsdist = true
|
skipsdist = true
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
previous: ansible>=2.9, <2.10
|
ansible5: ansible == 5.*
|
||||||
current: ansible
|
ansible6: ansible == 6.*
|
||||||
next: git+https://github.com/ansible/ansible.git@devel
|
ansible7: ansible == 7.*
|
||||||
molecule[docker]>=3, <4
|
molecule[docker]
|
||||||
docker>=4.2, <4.3
|
docker == 6.*
|
||||||
ansible-lint
|
ansible-lint == 6.*
|
||||||
commands = molecule test
|
commands = molecule test
|
||||||
setenv =
|
setenv =
|
||||||
TOX_ENVNAME={envname}
|
TOX_ENVNAME={envname}
|
||||||
PY_COLORS=1
|
PY_COLORS=1
|
||||||
ANSIBLE_FORCE_COLOR=1
|
ANSIBLE_FORCE_COLOR=1
|
||||||
|
ANSIBLE_ROLES_PATH=../
|
||||||
|
|
||||||
passenv = namespace image tag
|
passenv =
|
||||||
|
namespace
|
||||||
|
image
|
||||||
|
tag
|
||||||
|
DOCKER_HOST
|
||||||
|
|
|
@ -6,7 +6,7 @@ _bootstrap_packages:
|
||||||
Archlinux: python sudo
|
Archlinux: python sudo
|
||||||
Debian: python3 sudo gnupg python3-apt
|
Debian: python3 sudo gnupg python3-apt
|
||||||
Gentoo: python sudo gentoolkit
|
Gentoo: python sudo gentoolkit
|
||||||
RedHat: python3 sudo
|
RedHat: &redhat_packages python3 sudo
|
||||||
Suse: python3 python3-xml sudo
|
Suse: python3 python3-xml sudo
|
||||||
Amazon: python sudo
|
Amazon: python sudo
|
||||||
CentOS_7: python sudo
|
CentOS_7: python sudo
|
||||||
|
@ -14,6 +14,11 @@ _bootstrap_packages:
|
||||||
Debian_9: python sudo gnupg
|
Debian_9: python sudo gnupg
|
||||||
RedHat_7: python sudo
|
RedHat_7: python sudo
|
||||||
|
|
||||||
|
# Map the right set of packages, based on gathered bootstrap facts.
|
||||||
|
bootstrap_packages: "{{ _bootstrap_packages[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version]|default(
|
||||||
|
_bootstrap_packages[bootstrap_distribution] )|default(
|
||||||
|
_bootstrap_packages[bootstrap_os_family] ) }}"
|
||||||
|
|
||||||
_bootstrap_install:
|
_bootstrap_install:
|
||||||
Alpine:
|
Alpine:
|
||||||
raw: "LANG=C apk update ; apk add {{ bootstrap_packages }}"
|
raw: "LANG=C apk update ; apk add {{ bootstrap_packages }}"
|
||||||
|
@ -35,18 +40,25 @@ _bootstrap_install:
|
||||||
raw: "LANG=C zypper -n install {{ bootstrap_packages }}"
|
raw: "LANG=C zypper -n install {{ bootstrap_packages }}"
|
||||||
stdout_regex: 'Nothing'
|
stdout_regex: 'Nothing'
|
||||||
|
|
||||||
|
# Map the right install command, based on gathered bootstrap facts.
|
||||||
|
bootstrap_install: "{{ _bootstrap_install[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version]|default(
|
||||||
|
_bootstrap_install[bootstrap_distribution] )|default(
|
||||||
|
_bootstrap_install[bootstrap_os_family] ) }}"
|
||||||
|
|
||||||
# See URL for available OS families and search queries
|
# See URL for available OS families and search queries
|
||||||
# https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py
|
# https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py
|
||||||
bootstrap_os_family_map:
|
bootstrap_os_family_map:
|
||||||
Alpine: [Alpine]
|
Alpine: [Alpine]
|
||||||
Archlinux: [Archlinux, Antergos, Manjaro]
|
Archlinux: [Archlinux, Antergos, Manjaro]
|
||||||
Debian: [Debian, Ubuntu, Raspbian, Neon, KDE neon,
|
Debian: [Debian, Ubuntu, Raspbian, Neon, KDE neon,
|
||||||
Linux Mint, SteamOS, Devuan, Kali, 'Cumulus Linux']
|
Linux Mint, SteamOS, Devuan, Kali, Cumulus Linux,
|
||||||
|
'Pop!_OS', Parrot, Pardus GNU/Linux]
|
||||||
Gentoo: [Gentoo, Funtoo]
|
Gentoo: [Gentoo, Funtoo]
|
||||||
RedHat: [RedHat, Fedora, CentOS, Scientific, SLC,
|
RedHat: [RedHat, Fedora, CentOS, Scientific, SLC,
|
||||||
Ascendos, CloudLinux, PSBM, OracleLinux, OVS,
|
Ascendos, CloudLinux, PSBM, Rocky, OracleLinux,
|
||||||
OEL, Amazon, Virtuozzo, XenServer, Alibaba]
|
OVS, OEL, Amazon, Virtuozzo, XenServer, Alibaba,
|
||||||
Suse: [SLED, 'openSUSE Tumbleweed', 'openSUSE Leap',
|
EulerOS, openEuler, AlmaLinux]
|
||||||
|
Suse: [SLED, openSUSE Tumbleweed, openSUSE Leap,
|
||||||
SLES_SAP, SUSE_LINUX, SLES, openSUSE, SuSE]
|
SLES_SAP, SUSE_LINUX, SLES, openSUSE, SuSE]
|
||||||
|
|
||||||
bootstrap_search:
|
bootstrap_search:
|
||||||
|
@ -54,17 +66,7 @@ bootstrap_search:
|
||||||
OracleLinux: 'Oracle Linux'
|
OracleLinux: 'Oracle Linux'
|
||||||
RedHat: 'Red Hat'
|
RedHat: 'Red Hat'
|
||||||
|
|
||||||
# Map the right set of packages, based on gathered bootstrap facts.
|
|
||||||
bootstrap_packages: "{{ _bootstrap_packages[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version]|default(
|
|
||||||
_bootstrap_packages[bootstrap_distribution])|default(
|
|
||||||
_bootstrap_packages[bootstrap_os_family]) }}"
|
|
||||||
|
|
||||||
# Map the right install command, based on gathered bootstrap facts.
|
|
||||||
bootstrap_install: "{{ _bootstrap_install[bootstrap_distribution ~'_'~ bootstrap_distribution_major_version]|default(
|
|
||||||
_bootstrap_install[bootstrap_distribution])|default(
|
|
||||||
_bootstrap_install[bootstrap_os_family]) }}"
|
|
||||||
|
|
||||||
# Map the right set of packages, based on gathered ansible_facts.
|
# Map the right set of packages, based on gathered ansible_facts.
|
||||||
bootstrap_facts_packages: "{{ _bootstrap_packages[ansible_distribution ~'_'~ ansible_distribution_major_version]|default(
|
bootstrap_facts_packages: "{{ _bootstrap_packages[ansible_distribution ~'_'~ ansible_distribution_major_version]|default(
|
||||||
_bootstrap_packages[ansible_distribution])|default(
|
_bootstrap_packages[ansible_distribution] )|default(
|
||||||
_bootstrap_packages[ansible_os_family]) }}"
|
_bootstrap_packages[ansible_os_family] ) }}"
|
||||||
|
|
Loading…
Reference in a new issue