-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a9f09b
commit e71a7f9
Showing
9 changed files
with
230 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
- name: Deploy docker packages | ||
hosts: all | ||
become: true | ||
roles: | ||
- nephelaiio.docker | ||
pre_tasks: | ||
- name: Query Debian package versions | ||
ansible.builtin.shell: | ||
cmd: "apt-cache madison {{ item }} | awk -F'|' '{ print $2 }'" | ||
loop: "{{ docker_packages }}" | ||
register: _debian_package_query | ||
when: ansible_os_family == "Debian" | ||
changed_when: false | ||
|
||
- name: Query RedHat package versions | ||
ansible.builtin.shell: | ||
cmd: "yum list {{ item }} --showduplicates | grep '^{{ item }}' | awk '{ print $1,$2 }' | sort -r" | ||
loop: "{{ docker_packages }}" | ||
register: _redhat_package_query | ||
when: ansible_os_family == "RedHat" | ||
changed_when: false | ||
|
||
- name: Set package version facts | ||
ansible.builtin.set_fact: | ||
_docker_package_query: "{{ _redhat_packages + _debian_packages }}" | ||
vars: | ||
_redhat_packages: "{{ [] if _redhat_package_query.skipped else _redhat_package_query.results }}" | ||
_debian_packages: "{{ [] if _debian_package_query.skipped else _debian_package_query.results }}" | ||
|
||
- name: Verify target package versions | ||
ansible.builtin.fail: | ||
msg: "{{ _package }} has no installation candidate: {{ item }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_package: "{{ item.item }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _docker_package_query }}" | ||
when: _stdout | length == 0 | ||
|
||
- name: Initialize package versions | ||
ansible.builtin.set_fact: | ||
docker_packages: [] | ||
|
||
- name: Set target Debian package versions | ||
ansible.builtin.set_fact: | ||
docker_packages: "{{ docker_packages + [_package] }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_multiple: "{{ _stdout | length > 1 }}" | ||
_version: "{{ _stdout[0] if not _multiple else _stdout[1] }}" | ||
_package: "{{ item.item }}={{ _version | trim }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _docker_package_query }}" | ||
when: ansible_os_family == "Debian" | ||
|
||
- name: Set target RedHat package versions | ||
ansible.builtin.set_fact: | ||
docker_packages: "{{ docker_packages + [_package] }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_multiple: "{{ _stdout | length > 1 }}" | ||
_target: "{{ (_stdout[0] if not _multiple else _stdout[1]).split(' ') }}" | ||
_arch: "{{ _target[0].split('.')[1] }}" | ||
_name: "{{ _target[0].split('.')[0] }}" | ||
_version: "{{ _target[1] }}" | ||
_package: "{{ _name }}-{{ _version }}.{{ _arch }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _docker_package_query }}" | ||
when: ansible_os_family == "RedHat" |
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 |
---|---|---|
|
@@ -19,7 +19,3 @@ provisioner: | |
name: ansible | ||
verifier: | ||
name: ansible | ||
lint: | | ||
set -e | ||
run yamllint . | ||
run ansible-lint . |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
- name: Update OS | ||
hosts: all | ||
become: true | ||
roles: | ||
- robertdebock.update | ||
serial: 1 | ||
tasks: | ||
- name: Wait for MongoDB to be up | ||
community.mongodb.mongodb_shell: | ||
eval: "db.runCommand({ping: 1})" | ||
mongo_cmd: "{{ mongodb_shell | default(omit) }}" | ||
retries: 6 | ||
delay: 10 |
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
- name: Verify docker packages | ||
hosts: all | ||
become: true | ||
tasks: | ||
- name: Query Debian package versions | ||
ansible.builtin.shell: | ||
cmd: "apt-cache madison {{ item }} | awk -F'|' '{ print $2 }'" | ||
loop: "{{ docker_packages }}" | ||
register: _debian_package_query | ||
when: ansible_os_family == 'Debian' | ||
changed_when: false | ||
|
||
- name: Query RedHat package versions | ||
ansible.builtin.shell: | ||
cmd: "yum list {{ item }} --showduplicates | grep '^{{ item }}' | awk '{ print $1,$2 }' | sort -r" | ||
loop: "{{ docker_packages }}" | ||
register: _redhat_package_query | ||
when: ansible_os_family == "RedHat" | ||
changed_when: false | ||
|
||
- name: Set package version facts | ||
ansible.builtin.set_fact: | ||
_docker_package_query: "{{ _redhat_packages + _debian_packages }}" | ||
vars: | ||
_redhat_packages: "{{ [] if _redhat_package_query.skipped else _redhat_package_query.results }}" | ||
_debian_packages: "{{ [] if _debian_package_query.skipped else _debian_package_query.results }}" | ||
|
||
- name: Initialize package versions | ||
ansible.builtin.set_fact: | ||
docker_package_list: [] | ||
|
||
- name: Set target Debian package versions | ||
ansible.builtin.set_fact: | ||
docker_package_list: "{{ docker_package_list + [_package] }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_multiple: "{{ _stdout | length > 1 }}" | ||
_version: "{{ _stdout[0] if not _multiple else _stdout[1] }}" | ||
_package: "{{ item.item }}={{ _version | trim }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _docker_package_query }}" | ||
when: ansible_os_family == "Debian" | ||
|
||
- name: Set target RedHat package versions | ||
ansible.builtin.set_fact: | ||
docker_package_list: "{{ docker_package_list + [_package] }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_multiple: "{{ _stdout | length > 1 }}" | ||
_target: "{{ (_stdout[0] if not _multiple else _stdout[1]).split(' ') }}" | ||
_arch: "{{ _target[0].split('.')[1] }}" | ||
_name: "{{ _target[0].split('.')[0] }}" | ||
_version: "{{ _target[1] }}" | ||
_package: "{{ _name }}-{{ _version }}.{{ _arch }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _docker_package_query }}" | ||
when: ansible_os_family == "RedHat" | ||
|
||
- name: Gather package facts | ||
ansible.builtin.package_facts: | ||
|
||
- name: Verify package versions | ||
ansible.builtin.fail: | ||
msg: "Expected installed version for package {{ _package }} to be {{ _version }}, found {{ _installed }}" | ||
vars: | ||
_package: "{{ item.split('=') | first }}" | ||
_version: "{{ item.split('=') | last }}" | ||
_installed: "{{ (packages[_package] | default([{'version': 'None'}]))[0].version }}" | ||
loop: "{{ docker_package_list }}" | ||
when: | ||
- ansible_os_family == "Debian" | ||
- _package not in packages or _version != _installed | ||
|
||
- name: Verify package versions | ||
ansible.builtin.fail: | ||
msg: "Expected installed version for package {{ _package }} to be {{ _version }}, found {{ _installed }}" | ||
vars: | ||
_prefix: "^{{ _package }}-" | ||
_suffix: "-.*$" | ||
_package: "{{ item.0 }}" | ||
_version: "{{ item.1 | regex_replace(_prefix, '') | regex_replace(_suffix, '') }}" | ||
_installed: "{{ (packages[_package] | default([{'version': 'None'}]))[0].version }}" | ||
loop: "{{ docker_packages | zip(docker_package_list) }}" | ||
when: | ||
- ansible_os_family == "RedHat" | ||
- _package not in packages or _version != _installed |
10 changes: 2 additions & 8 deletions
10
molecule/default/converge.yml → molecule/install/converge.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,23 +1,17 @@ | ||
--- | ||
- name: Converge | ||
|
||
hosts: all | ||
|
||
roles: | ||
|
||
- nephelaiio.docker | ||
|
||
pre_tasks: | ||
|
||
- name: update apt package cache | ||
- name: Update apt package cache | ||
apt: | ||
package: gpg-agent | ||
update_cache: true | ||
when: ansible_os_family == 'Debian' | ||
|
||
post_tasks: | ||
|
||
- name: install python3 binary redirection | ||
- name: Install python3 binary redirection | ||
apt: | ||
name: python-is-python3 | ||
when: ansible_os_family == 'Debian' |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible | ||
pre_build_image: true | ||
command: ${MOLECULE_COMMAND:-"/lib/systemd/systemd"} | ||
cgroupns_mode: host | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
privileged: true | ||
tmpfs: | ||
- /tmp | ||
- /opt | ||
provisioner: | ||
name: ansible | ||
verifier: | ||
name: ansible |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Verify | ||
hosts: all | ||
vars: | ||
docker_service: docker.service | ||
pre_tasks: | ||
- name: Verify docker cli is installed | ||
ansible.builtin.command: "docker --version" | ||
|
||
- name: Verify docker pip is installed | ||
ansible.builtin.command: "python3 -c import docker" | ||
|
||
- name: Gather service facts | ||
ansible.builtin.service_facts: | ||
|
||
- name: Check service definition | ||
ansible.builtin.assert: | ||
that: docker service is available | ||
when: _service not in ansible_facts.services | ||
|
||
- name: Check service running state | ||
ansible.builtin.assert: | ||
that: docker service is running | ||
when: ansible_facts.services[_service].state != "running" | ||
|
||
- name: Check service startup state | ||
ansible.builtin.assert: | ||
that: docker service is running | ||
when: ansible_facts.services[_service].status != "enabled" |
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 @@ | ||
--- | ||
roles: | ||
- nephelaiio.plugins | ||
- name: robertdebock.update | ||
- nephelaiio.pip | ||
collections: | ||
- community.docker | ||
- nephelaiio.plugins |