Change yes/no to true/false, adhere to yamlspec 1.2.2

This commit is contained in:
Robert de Bock 2024-03-18 09:52:29 +01:00
parent 40e126e32b
commit 40c0544ce6
10 changed files with 31 additions and 34 deletions

View File

@ -31,5 +31,5 @@ jobs:
uses: ad-m/github-push-action@master
with:
directory: ${{ github.repository }}
force: yes
force: true
branch: png

View File

@ -11,9 +11,6 @@ rules:
line-length: disable
truthy:
check-keys: no
allowed-values:
- "yes"
- "no"
ignore: |
.tox/

View File

@ -16,13 +16,13 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/
hosts: all
# 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.
# role have `become` set to `false`, so you can use either `false` or `true`
# for `become`, the role will not use become (so `sudo`) for any task.
become: true # `false` 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: false
roles:
- role: robertdebock.bootstrap
@ -39,13 +39,13 @@ The default values for the variables are set in [`defaults/main.yml`](https://gi
# defaults file for bootstrap
# Do you want to wait for the host to be available?
bootstrap_wait_for_host: no
bootstrap_wait_for_host: false
# The number of seconds you want to wait during connection test before failing.
bootstrap_timeout: 3
# Tell the role to "become" or not.
bootstrap_become: yes
bootstrap_become: true
```
## [Requirements](#requirements)

View File

@ -2,10 +2,10 @@
# defaults file for bootstrap
# Do you want to wait for the host to be available?
bootstrap_wait_for_host: no
bootstrap_wait_for_host: false
# The number of seconds you want to wait during connection test before failing.
bootstrap_timeout: 3
# Tell the role to "become" or not.
bootstrap_become: yes
bootstrap_become: true

View File

@ -10,7 +10,7 @@ argument_specs:
options:
bootstrap_wait_for_host:
type: "bool"
default: no
default: false
description: "Wait for the machine to be available."
bootstrap_timeout:
type: "int"

View File

@ -3,13 +3,13 @@
hosts: all
# 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.
# role have `become` set to `false`, so you can use either `false` or `true`
# for `become`, the role will not use become (so `sudo`) for any task.
become: true # `false` 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: false
roles:
- role: ansible-role-bootstrap

View File

@ -1,8 +1,8 @@
---
- name: Verify
hosts: all
become: no
gather_facts: no
become: false
gather_facts: false
tasks:
- name: Test connection

View File

@ -5,7 +5,7 @@
that:
- bootstrap_wait_for_host is defined
- bootstrap_wait_for_host is boolean
quiet: yes
quiet: true
- name: assert | Test bootstrap_timeout
ansible.builtin.assert:
@ -13,11 +13,11 @@
- bootstrap_timeout is defined
- bootstrap_timeout is number
- bootstrap_timeout >= 0
quiet: yes
quiet: true
- name: assert | Test bootstrap_become
ansible.builtin.assert:
that:
- bootstrap_become is defined
- bootstrap_become is boolean
quiet: yes
quiet: true

View File

@ -2,10 +2,10 @@
- name: gather_facts | Lookup bootstrap facts
ansible.builtin.raw: "cat /etc/os-release"
become: no
check_mode: no
become: false
check_mode: false
register: bootstrap_facts
changed_when: no
changed_when: false
- name: gather_facts | Set bootstrap facts (I)
ansible.builtin.set_fact:
@ -16,7 +16,7 @@
- bootstrap_facts.rc == 0
- bootstrap_distribution is not defined
- bootstrap_facts.stdout is regex('PRETTY_NAME=.'~ bootstrap_search[item] | default(item) ~'.*')
become: no
become: false
- name: gather_facts | Set bootstrap facts (II)
ansible.builtin.set_fact:
@ -26,4 +26,4 @@
label: "{{ item.key }}"
when:
- bootstrap_distribution in item.value
become: no
become: false

View File

@ -4,14 +4,14 @@
- name: Import assert.yml
ansible.builtin.import_tasks:
file: assert.yml
run_once: yes
run_once: true
delegate_to: localhost
- name: Wait for port to be available
ansible.builtin.wait_for:
port: "{{ ansible_port | default('22') }}"
timeout: "{{ bootstrap_timeout }}"
become: no
become: false
when:
- ansible_connection is defined
- ansible_connection not in [ "container", "docker", "community.docker.docker" ]
@ -20,17 +20,17 @@
- name: Prepare system
# At this stage, python and/or sudo are not installed, `become` can't be used.
become: no
become: false
block:
- name: Test connection
ansible.builtin.wait_for_connection:
timeout: "{{ bootstrap_timeout }}"
register: bootstrap_connect
changed_when: no
changed_when: false
- name: Test sudo
ansible.builtin.command:
cmd: sudo --version
changed_when: no
changed_when: false
rescue:
- name: Gather bootstrap facts
ansible.builtin.include_tasks:
@ -49,12 +49,12 @@
- name: Gather ansible facts
ansible.builtin.setup:
become: no
become: false
- name: Install bootstrap packages (package)
ansible.builtin.package:
name: "{{ item }}"
state: present
update_cache: yes
update_cache: true
loop: "{{ bootstrap_facts_packages.split() }}"
become: "{{ bootstrap_become }}"