fix ansible-lint

This commit is contained in:
juju4 2023-02-04 18:45:38 +00:00
parent 67e50e9af0
commit cd44a7c077
9 changed files with 69 additions and 55 deletions

View File

@ -40,7 +40,7 @@ docker_apt_ignore_key_error: true
docker_apt_gpg_key: "{{ docker_repo_url }}/{{ ansible_distribution | lower }}/gpg"
# Used only for RedHat/CentOS/Fedora.
docker_yum_repo_url: "{{ docker_repo_url }}/{{ (ansible_distribution == 'Fedora') | ternary('fedora','centos') }}/docker-{{ docker_edition }}.repo"
docker_yum_repo_url: "{{ docker_repo_url }}/{{ (ansible_distribution == 'Fedora') | ternary('fedora', 'centos') }}/docker-{{ docker_edition }}.repo"
docker_yum_repo_enable_nightly: '0'
docker_yum_repo_enable_test: '0'
docker_yum_gpg_key: "{{ docker_repo_url }}/centos/gpg"

View File

@ -1,6 +1,6 @@
---
- name: restart docker
service:
- name: Restart docker
ansible.builtin.service:
name: docker
state: "{{ docker_restart_handler_state }}"
ignore_errors: "{{ ansible_check_mode }}"

View File

@ -7,12 +7,12 @@ galaxy_info:
description: Docker for Linux.
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.4
min_ansible_version: '2.4'
platforms:
- name: EL
versions:
- 7
- 8
- '7'
- '8'
- name: Fedora
versions:
- all

View File

@ -5,11 +5,13 @@
pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
ansible.builtin.apt:
update_cache: yes
cache_valid_time: 600
when: ansible_os_family == 'Debian'
- name: Wait for systemd to complete initialization. # noqa 303
command: systemctl is-system-running
- name: Wait for systemd to complete initialization. # noqa command-instead-of-module
ansible.builtin.command: systemctl is-system-running
register: systemctl_status
until: >
'running' in systemctl_status.stdout or

View File

@ -1,19 +1,20 @@
---
- name: Check current docker-compose version.
command: "{{ docker_compose_path }} --version"
ansible.builtin.command: "{{ docker_compose_path }} --version"
register: docker_compose_vsn
check_mode: false
changed_when: false
failed_when: false
- set_fact:
- name: Set fact docker_compose_current_version
ansible.builtin.set_fact:
docker_compose_current_version: "{{ docker_compose_vsn.stdout | regex_search('(\\d+(\\.\\d+)+)') }}"
when: >
docker_compose_vsn.stdout is defined
and (docker_compose_vsn.stdout | length > 0)
- name: Delete existing docker-compose version if it's different.
file:
ansible.builtin.file:
path: "{{ docker_compose_path }}"
state: absent
when: >
@ -21,7 +22,7 @@
and (docker_compose_version | regex_replace('v', '')) not in docker_compose_current_version
- name: Install Docker Compose (if configured).
get_url:
ansible.builtin.get_url:
url: "{{ docker_compose_url }}"
dest: "{{ docker_compose_path }}"
mode: 0755

View File

@ -1,10 +1,10 @@
---
- name: Ensure docker users are added to the docker group.
user:
ansible.builtin.user:
name: "{{ item }}"
groups: docker
append: true
with_items: "{{ docker_users }}"
- name: Reset ssh connection to apply user changes.
meta: reset_connection
ansible.builtin.meta: reset_connection

View File

@ -1,72 +1,79 @@
---
- name: Load OS-specific vars.
include_vars: "{{ lookup('first_found', params) }}"
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ansible_distribution}}.yml'
- '{{ansible_os_family}}.yml'
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
- main.yml
paths:
- 'vars'
- include_tasks: setup-RedHat.yml
- name: Include setup-RedHat
ansible.builtin.include_tasks: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
- include_tasks: setup-Debian.yml
- name: Include setup-Debian
ansible.builtin.include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
- name: Install Docker packages.
package:
ansible.builtin.package:
name: "{{ docker_packages }}"
state: "{{ docker_packages_state }}"
notify: restart docker
notify: Restart docker
ignore_errors: "{{ ansible_check_mode }}"
when: "ansible_version.full is version_compare('2.12', '<') or ansible_os_family not in ['RedHat', 'Debian']"
- name: Install Docker packages (with downgrade option).
package:
ansible.builtin.package:
name: "{{ docker_packages }}"
state: "{{ docker_packages_state }}"
allow_downgrade: true
notify: restart docker
notify: Restart docker
ignore_errors: "{{ ansible_check_mode }}"
when: "ansible_version.full is version_compare('2.12', '>=') and ansible_os_family in ['RedHat', 'Debian']"
- name: Install docker-compose plugin.
package:
ansible.builtin.package:
name: "{{ docker_compose_package }}"
state: "{{ docker_compose_package_state }}"
notify: restart docker
notify: Restart docker
ignore_errors: "{{ ansible_check_mode }}"
when: "docker_install_compose_plugin | bool == true and (ansible_version.full is version_compare('2.12', '<') or ansible_os_family not in ['RedHat', 'Debian'])"
when:
- docker_install_compose_plugin | bool
- (ansible_version.full is version_compare('2.12', '<') or ansible_os_family not in ['RedHat', 'Debian'])
- name: Install docker-compose-plugin (with downgrade option).
package:
ansible.builtin.package:
name: "{{ docker_compose_package }}"
state: "{{ docker_compose_package_state }}"
allow_downgrade: true
notify: restart docker
notify: Restart docker
ignore_errors: "{{ ansible_check_mode }}"
when: "docker_install_compose_plugin | bool == true and ansible_version.full is version_compare('2.12', '>=') and ansible_os_family in ['RedHat', 'Debian']"
when:
- docker_install_compose_plugin | bool
- ansible_version.full is version_compare('2.12', '>=')
- ansible_os_family in ['RedHat', 'Debian']
- name: Ensure /etc/docker/ directory exists.
file:
ansible.builtin.file:
path: /etc/docker
state: directory
mode: 0755
when: docker_daemon_options.keys() | length > 0
- name: Configure Docker daemon options.
copy:
ansible.builtin.copy:
content: "{{ docker_daemon_options | to_nice_json }}"
dest: /etc/docker/daemon.json
mode: 0644
when: docker_daemon_options.keys() | length > 0
notify: restart docker
notify: Restart docker
- name: Ensure Docker is started and enabled at boot.
service:
ansible.builtin.service:
name: docker
state: "{{ docker_service_state }}"
enabled: "{{ docker_service_enabled }}"
@ -74,25 +81,27 @@
when: docker_service_manage | bool
- name: Ensure handlers are notified now to avoid firewall conflicts.
meta: flush_handlers
ansible.builtin.meta: flush_handlers
- include_tasks: docker-compose.yml
- name: Include docker-compose
ansible.builtin.include_tasks: docker-compose.yml
when: docker_install_compose | bool
- name: Get docker group info using getent.
getent:
ansible.builtin.getent:
database: group
key: docker
split: ':'
when: docker_users | length > 0
- name: Check if there are any users to add to the docker group.
set_fact:
ansible.builtin.set_fact:
at_least_one_user_to_modify: true
when:
- docker_users | length > 0
- item not in ansible_facts.getent_group["docker"][2]
with_items: "{{ docker_users }}"
- include_tasks: docker-users.yml
- name: Include docker-users
ansible.builtin.include_tasks: docker-users.yml
when: at_least_one_user_to_modify is defined

View File

@ -1,13 +1,13 @@
---
- name: Ensure old versions of Docker are not installed.
package:
ansible.builtin.package:
name:
- docker
- docker-engine
state: absent
- name: Ensure dependencies are installed.
apt:
ansible.builtin.apt:
name:
- apt-transport-https
- ca-certificates
@ -15,13 +15,13 @@
when: docker_add_repo | bool
- name: Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems).
apt:
ansible.builtin.apt:
name: gnupg2
state: present
when: ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('20.04', '<')
- name: Ensure additional dependencies are installed (on Ubuntu >= 20.04).
apt:
ansible.builtin.apt:
name: gnupg
state: present
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '>=')
@ -37,16 +37,18 @@
when: docker_add_repo | bool
- name: Ensure curl is present (on older systems without SNI).
package: name=curl state=present
ansible.builtin.package:
name: curl
state: present
when: add_repository_key is failed and docker_add_repo | bool
- name: Add Docker apt key (alternative for older systems without SNI).
shell: >
- name: Add Docker apt key (alternative for older systems without SNI). # noqa command-instead-of-module
ansible.builtin.shell: >
curl -sSL {{ docker_apt_gpg_key }} | apt-key add -
when: add_repository_key is failed and docker_add_repo | bool
- name: Add Docker repository.
apt_repository:
ansible.builtin.apt_repository:
repo: "{{ docker_apt_repository }}"
state: present
update_cache: true

View File

@ -1,6 +1,6 @@
---
- name: Ensure old versions of Docker are not installed.
package:
ansible.builtin.package:
name:
- docker
- docker-common
@ -8,13 +8,13 @@
state: absent
- name: Add Docker GPG key.
rpm_key:
ansible.builtin.rpm_key:
key: "{{ docker_yum_gpg_key }}"
state: present
when: docker_add_repo | bool
- name: Add Docker repository.
get_url:
ansible.builtin.get_url:
url: "{{ docker_yum_repo_url }}"
dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
owner: root
@ -23,7 +23,7 @@
when: docker_add_repo | bool
- name: Configure Docker Nightly repo.
ini_file:
community.general.ini_file:
dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
section: 'docker-{{ docker_edition }}-nightly'
option: enabled
@ -33,7 +33,7 @@
when: docker_add_repo | bool
- name: Configure Docker Test repo.
ini_file:
community.general.ini_file:
dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
section: 'docker-{{ docker_edition }}-test'
option: enabled
@ -43,14 +43,14 @@
when: docker_add_repo | bool
- name: Configure containerd on RHEL 8.
when: ansible_distribution_major_version | int == 8
block:
- name: Ensure container-selinux is installed.
package:
ansible.builtin.package:
name: container-selinux
state: present
- name: Ensure containerd.io is installed.
package:
ansible.builtin.package:
name: containerd.io
state: present
when: ansible_distribution_major_version | int == 8