-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ansible-lint to format ansible files
Add ansible-lint to the pre-commit-config file, and fix failures/warnings for ansible files as well. Signed-off-by: Vector Li <huanli@redhat.com>
- Loading branch information
Showing
10 changed files
with
128 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
- hosts: all | ||
- name: Install packages | ||
hosts: all | ||
tasks: | ||
- name: Install necessary dependencies | ||
dnf: | ||
state: present | ||
name: tmt | ||
- name: Install necessary dependencies | ||
ansible.builtin.dnf: | ||
state: present | ||
name: tmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
- hosts: localhost | ||
- name: A simple test | ||
hosts: localhost | ||
tasks: | ||
- name: Create a simple test file | ||
copy: | ||
ansible.builtin.copy: | ||
dest: /tmp/prepared | ||
content: pass | ||
mode: preserve | ||
- name: Check the file content | ||
shell: grep pass /tmp/prepared | ||
ansible.builtin.command: grep pass /tmp/prepared | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
--- | ||
- hosts: all | ||
- name: Setup server | ||
hosts: all | ||
vars: | ||
- version: "{{ ansible_distribution_version }}" | ||
version: "{{ ansible_distribution_version }}" | ||
tasks: | ||
- import_tasks: tasks/redis.yml | ||
- import_tasks: tasks/redis_variables.yml | ||
- name: Task redis | ||
ansible.builtin.import_tasks: tasks/redis.yml | ||
- name: Task redis variables | ||
ansible.builtin.import_tasks: tasks/redis_variables.yml | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
- name: Set variables into redis database | ||
ansible.builtin.shell: | | ||
ansible.builtin.command: | | ||
redis-cli set key value1 | ||
changed_when: false | ||
args: | ||
executable: /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
- hosts: all | ||
- name: A simple playbook in finish phase | ||
hosts: all | ||
vars: | ||
simple: "{{ lookup('env', 'SIMPLE') }}" | ||
spaces: "{{ lookup('env', 'SPACES') }}" | ||
tasks: | ||
- name: Create a simple test file | ||
copy: | ||
ansible.builtin.copy: | ||
dest: /tmp/finished | ||
content: pass | ||
mode: preserve | ||
|
||
- name: Make sure a simple environment variable is respected | ||
command: echo "SIMPLE='{{ simple }}'" | ||
ansible.builtin.command: echo "SIMPLE='{{ simple }}'" | ||
failed_when: simple != 'word' | ||
changed_when: false | ||
|
||
- name: Make sure variables with spaces are correctly handed over | ||
command: echo "SPACES='{{ spaces }}'" | ||
ansible.builtin.command: echo "SPACES='{{ spaces }}'" | ||
failed_when: spaces != 'several words with spaces' | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
- hosts: all | ||
- name: Copy and check test file | ||
hosts: all | ||
tasks: | ||
- copy: | ||
- name: Copy test file | ||
ansible.builtin.copy: | ||
src: testfile | ||
dest: /tmp/testfile | ||
- command: grep PASS /tmp/testfile | ||
mode: preserve | ||
- name: Check test file | ||
ansible.builtin.command: grep PASS /tmp/testfile | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,54 @@ | ||
- hosts: all | ||
- name: Disable EPEL repositories | ||
hosts: all | ||
tasks: | ||
# RHEL 7 or CentOS 7 | ||
- when: ansible_distribution_major_version|int == 7 | ||
- name: Disable EPEL repos on RHEL 7 or CentOS 7 | ||
when: ansible_distribution in ["RedHat", "CentOS"] and ansible_distribution_major_version | int == 7 | ||
block: | ||
- name: Install package 'yum-utils' | ||
ansible.builtin.yum: | ||
name: yum-utils | ||
state: present | ||
|
||
# Disable repos of 'epel' if package 'epel-release' is installed | ||
- name: Detect package 'epel-release' is installed | ||
command: rpm -q epel-release | ||
ansible.builtin.command: rpm -q epel-release # noqa: command-instead-of-module | ||
register: result | ||
ignore_errors: True | ||
ignore_errors: true | ||
changed_when: false | ||
|
||
- name: Disable repos of 'epel' | ||
shell: yum-config-manager --disable epel epel-debuginfo epel-source | ||
- name: Disable EPEL repos | ||
when: result.rc == 0 | ||
ansible.builtin.command: yum-config-manager --disable epel epel-debuginfo epel-source | ||
register: output | ||
changed_when: output.rc != 0 | ||
|
||
# RHEL N or CentOS Stream N where N >= 8 | ||
- when: ansible_distribution_major_version|int >= 8 | ||
- name: Disable EPEL and EPEL-Next repos on RHEL 8+ or CentOS Stream 8+ | ||
when: ansible_distribution in ["RedHat", "CentOS"] and ansible_distribution_major_version | int >= 8 | ||
block: | ||
- name: Install 'dnf config-manager' | ||
shell: dnf -y install 'dnf-command(config-manager)' | ||
ansible.builtin.command: dnf -y install 'dnf-command(config-manager)' | ||
register: output | ||
changed_when: output.rc != 0 | ||
|
||
# Disable repos of 'epel' if package 'epel-release' is installed | ||
- name: Detect package 'epel-release' is installed | ||
command: rpm -q epel-release | ||
ansible.builtin.command: rpm -q epel-release # noqa: command-instead-of-module | ||
register: result | ||
ignore_errors: True | ||
ignore_errors: true | ||
changed_when: false | ||
|
||
- name: Disable repos of 'epel' if package 'epel-release' is installed | ||
shell: dnf config-manager --disable epel epel-debuginfo epel-source | ||
- name: Disable EPEL repos | ||
when: result.rc == 0 | ||
ansible.builtin.command: dnf config-manager --disable epel epel-debuginfo epel-source | ||
register: output | ||
changed_when: output.rc != 0 | ||
|
||
# Disable repos of 'epel-next' if package 'epel-next-release' is installed | ||
- name: Detect package 'epel-next-release' is installed | ||
command: rpm -q epel-next-release | ||
ansible.builtin.command: rpm -q epel-release # noqa: command-instead-of-module | ||
register: result | ||
ignore_errors: True | ||
ignore_errors: true | ||
changed_when: false | ||
|
||
- name: Disable repos of 'epel-next' | ||
shell: dnf config-manager --disable epel-next epel-next-debuginfo epel-next-source | ||
- name: Disable EPEL-Next repos | ||
when: result.rc == 0 | ||
ansible.builtin.command: dnf config-manager --disable epel-next epel-next-debuginfo epel-next-source | ||
register: output | ||
changed_when: output.rc != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters