Compare commits

..

3 Commits

Author SHA1 Message Date
dc8fae082c
fix dependencies
Some checks failed
continuous-integration/drone/pr Build is failing
2021-10-03 17:48:18 +02:00
7f2c7178f2
fix dependencies
Some checks failed
continuous-integration/drone/pr Build is failing
2021-10-03 17:35:40 +02:00
6b4742e83c
feat: add test for Rocky Linux 8
Some checks failed
continuous-integration/drone/pr Build is failing
2021-10-03 16:32:29 +02:00
26 changed files with 440 additions and 158 deletions

View File

@ -15,7 +15,7 @@ local PipelineLinting = {
}, },
{ {
name: 'python-format', name: 'python-format',
image: 'python:3.11', image: 'python:3.9',
environment: { environment: {
PY_COLORS: 1, PY_COLORS: 1,
}, },
@ -26,7 +26,7 @@ local PipelineLinting = {
}, },
{ {
name: 'python-flake8', name: 'python-flake8',
image: 'python:3.11', image: 'python:3.9',
environment: { environment: {
PY_COLORS: 1, PY_COLORS: 1,
}, },
@ -37,11 +37,11 @@ local PipelineLinting = {
}, },
], ],
trigger: { trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'], ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
}, },
}; };
local PipelineDeployment(scenario='rocky9') = { local PipelineDeployment(scenario='centos7') = {
kind: 'pipeline', kind: 'pipeline',
name: 'testing-' + scenario, name: 'testing-' + scenario,
platform: { platform: {
@ -58,7 +58,7 @@ local PipelineDeployment(scenario='rocky9') = {
steps: [ steps: [
{ {
name: 'ansible-molecule', name: 'ansible-molecule',
image: 'thegeeklab/molecule:4', image: 'thegeeklab/molecule:3',
environment: { environment: {
HCLOUD_TOKEN: { from_secret: 'hcloud_token' }, HCLOUD_TOKEN: { from_secret: 'hcloud_token' },
}, },
@ -71,7 +71,7 @@ local PipelineDeployment(scenario='rocky9') = {
'linting', 'linting',
], ],
trigger: { trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'], ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
}, },
}; };
@ -107,15 +107,16 @@ local PipelineDocumentation = {
target_branch: 'docs', target_branch: 'docs',
}, },
when: { when: {
ref: ['refs/heads/main'], ref: ['refs/heads/master'],
}, },
}, },
], ],
trigger: { trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'], ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
}, },
depends_on: [ depends_on: [
'testing-rocky9', 'testing-centos7',
'testing-rocky8',
], ],
}; };
@ -136,7 +137,7 @@ local PipelineNotification = {
settings: { settings: {
homeserver: { from_secret: 'matrix_homeserver' }, homeserver: { from_secret: 'matrix_homeserver' },
roomid: { from_secret: 'matrix_roomid' }, roomid: { from_secret: 'matrix_roomid' },
template: 'Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}', template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
username: { from_secret: 'matrix_username' }, username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' }, password: { from_secret: 'matrix_password' },
}, },
@ -147,13 +148,14 @@ local PipelineNotification = {
], ],
trigger: { trigger: {
status: ['success', 'failure'], status: ['success', 'failure'],
ref: ['refs/heads/main', 'refs/tags/**'], ref: ['refs/heads/master', 'refs/tags/**'],
}, },
}; };
[ [
PipelineLinting, PipelineLinting,
PipelineDeployment(scenario='rocky9'), PipelineDeployment(scenario='centos7'),
PipelineDeployment(scenario='rocky8'),
PipelineDocumentation, PipelineDocumentation,
PipelineNotification, PipelineNotification,
] ]

View File

@ -13,7 +13,7 @@ steps:
- ansible-later - ansible-later
- name: python-format - name: python-format
image: python:3.11 image: python:3.9
commands: commands:
- pip install -qq yapf - pip install -qq yapf
- "[ -z \"$(find . -type f -name *.py)\" ] || (yapf -rd ./)" - "[ -z \"$(find . -type f -name *.py)\" ] || (yapf -rd ./)"
@ -21,7 +21,7 @@ steps:
PY_COLORS: 1 PY_COLORS: 1
- name: python-flake8 - name: python-flake8
image: python:3.11 image: python:3.9
commands: commands:
- pip install -qq flake8 - pip install -qq flake8
- flake8 - flake8
@ -30,13 +30,13 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/master
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
--- ---
kind: pipeline kind: pipeline
name: testing-rocky9 name: testing-centos7
platform: platform:
os: linux os: linux
@ -51,16 +51,49 @@ workspace:
steps: steps:
- name: ansible-molecule - name: ansible-molecule
image: thegeeklab/molecule:4 image: thegeeklab/molecule:3
commands: commands:
- molecule test -s rocky9 - molecule test -s centos7
environment: environment:
HCLOUD_TOKEN: HCLOUD_TOKEN:
from_secret: hcloud_token from_secret: hcloud_token
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/master
- refs/tags/**
- refs/pull/**
depends_on:
- linting
---
kind: pipeline
name: testing-rocky8
platform:
os: linux
arch: amd64
concurrency:
limit: 1
workspace:
base: /drone/src
path: ${DRONE_REPO_NAME}
steps:
- name: ansible-molecule
image: thegeeklab/molecule:3
commands:
- molecule test -s rocky8
environment:
HCLOUD_TOKEN:
from_secret: hcloud_token
trigger:
ref:
- refs/heads/master
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
@ -99,16 +132,17 @@ steps:
from_secret: gitea_username from_secret: gitea_username
when: when:
ref: ref:
- refs/heads/main - refs/heads/master
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/master
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
depends_on: depends_on:
- testing-rocky9 - testing-centos7
- testing-rocky8
--- ---
kind: pipeline kind: pipeline
@ -131,13 +165,13 @@ steps:
from_secret: matrix_password from_secret: matrix_password
roomid: roomid:
from_secret: matrix_roomid from_secret: matrix_roomid
template: "Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}" template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}"
username: username:
from_secret: matrix_username from_secret: matrix_username
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/master
- refs/tags/** - refs/tags/**
status: status:
- success - success
@ -148,6 +182,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: 5ecb808a24d61708adad225a6fd1ffde1b8de1a477f513e21c5e2b14c3790e0d hmac: 831ec121b72e5f0e8b38cf1a819e321fbf903094b8681adebb7c7072d11a1f0e
... ...

2
.gitignore vendored
View File

@ -9,5 +9,3 @@ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
# ---> Docs
/_docs

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de> Copyright (c) 2021 Robert Kaussow <mail@thegeeklab.de>
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,10 +1,6 @@
--- ---
dockerengine_packages: dockerengine_packages:
- docker-ce - docker
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
# @var dockerengine_packages_extra:description: > # @var dockerengine_packages_extra:description: >
# The role requires epel repository and pip to work. You can use # The role requires epel repository and pip to work. You can use
@ -12,55 +8,35 @@ dockerengine_packages:
# @end # @end
dockerengine_packages_extra: [] dockerengine_packages_extra: []
dockerengine_ansible_deps:
- cryptography
- docker-compose
- docker
dockerengine_service: docker dockerengine_service: docker
# @var dockerengine_service_override_unit:description: >
# Multiline string of options to add to the `systemd` service override unit section.
# @end
# @var dockerengine_service_override_unit: $ "_unset_"
# @var dockerengine_service_override_unit:example: >
# dockerengine_service_override_unit: |
# After=time-sync.target
# Requires=time-sync.target
# @end
dockerengine_docker_group_enabled: False dockerengine_docker_group_enabled: False
dockerengine_secure_registries: []
# @var dockerengine_registries:description: List of docker registries to auto login dockerengine_insecure_registries: []
# @var dockerengine_registries:example: > dockerengine_block_registries: []
# dockerengine_registries:
# - registry: myregistry.example.com (optional)
# username: docker
# password: secure
# reauthorize: False
# state: present
# @end
dockerengine_registries: []
# @var dockerengine_http_proxy: $ "_unset_" # @var dockerengine_http_proxy: $ "_unset_"
# @var dockerengine_https_proxy: $ "_unset" # @var dockerengine_https_proxy: $ "_unset"
# @var dockerengine_no_proxy: $ "_unset_" # @var dockerengine_no_proxy: $ "_unset_"
# @var dockerengine_storage_pvs: $ "_unset_"
# @var dockerengine_storage_pvs:example: $ "/dev/sda"
dockerengine_storage_vg: vg_docker
dockerengine_storage_lv: lv_docker
dockerengine_storage_size: 100G
dockerengine_base_dir: /var/lib/docker
dockerengine_cli_options:
- selinux-enabled
- log-driver=journald
- log-level=info
- signature-verification=false
dockerengine_usernamespace_enabled: False dockerengine_usernamespace_enabled: False
dockerengine_nsremap_user: dockremap dockerengine_nsremap_user: dockremap
dockerengine_nsremap_range_start: 231072 dockerengine_nsremap_range_start: 231072
dockerengine_nsremap_range_length: 65536 dockerengine_nsremap_range_length: 65536
dockerengine_daemon_config:
- selinux-enabled: False
- log-driver: journald
- log-level: info
- live-restore: True
dockerengine_daemon_config_extra: []
# dockerengine_daemon_config_extra:
# - userns-remap: "{{ dockerengine_nsremap_user +':' + dockerengine_nsremap_user }}"
# @var dockerengine_networks:description: List of additional docker networks to create. # @var dockerengine_networks:description: List of additional docker networks to create.
# @var dockerengine_networks:example: > # @var dockerengine_networks:example: >
# dockerengine_networks: # dockerengine_networks:

View File

@ -8,7 +8,7 @@ galaxy_info:
# @meta description: > # @meta description: >
# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.docker_engine) # [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.docker_engine)
# [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.docker_engine?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.docker_engine) # [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.docker_engine?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.docker_engine)
# [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.docker_engine/src/branch/main/LICENSE) # [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.docker_engine/src/branch/master/LICENSE)
# #
# Setup docker engine. # Setup docker engine.
# @end # @end

View File

@ -6,9 +6,6 @@
- epel-release - epel-release
- python3-pip - python3-pip
- python3-virtualenv - python3-virtualenv
pre_tasks:
- name: Enable CodeReadyBuilder repository
command: dnf config-manager --set-enabled "crb"
changed_when: False
roles: roles:
- role: xoxys.docker_engine - role: xoxys.docker_engine

View File

@ -0,0 +1,24 @@
---
dependency:
name: galaxy
options:
role-file: molecule/requirements.yml
requirements-file: molecule/requirements.yml
env:
ANSIBLE_GALAXY_DISPLAY_PROGRESS: "false"
driver:
name: delegated
platforms:
- name: centos7-docker-engine
image: centos-7
server_type: cx11
lint: |
/usr/local/bin/flake8
provisioner:
name: ansible
env:
ANSIBLE_FILTER_PLUGINS: ${ANSIBLE_FILTER_PLUGINS:-./plugins/filter}
ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-./library}
log: False
verifier:
name: testinfra

View File

@ -8,7 +8,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
def test_docker_is_installed(host): def test_docker_is_installed(host):
docker = host.package("docker-ce") docker = host.package("docker")
assert docker.is_installed assert docker.is_installed

View File

@ -1 +1 @@
centos7 rocky8

View File

@ -0,0 +1,11 @@
---
- name: Converge
hosts: all
vars:
dockerengine_packages_extra:
- epel-release
- python3-pip
- python3-virtualenv
roles:
- role: xoxys.docker_engine

120
molecule/rocky8/create.yml Normal file
View File

@ -0,0 +1,120 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
ssh_port: 22
ssh_user: root
ssh_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
tasks:
- name: Create SSH key
user:
name: "{{ lookup('env', 'USER') }}"
generate_ssh_key: true
ssh_key_file: "{{ ssh_path }}"
force: true
register: generated_ssh_key
- name: Register the SSH key name
set_fact:
ssh_key_name: "molecule-generated-{{ 12345 | random | to_uuid }}"
- name: Register SSH key for test instance(s)
hcloud_ssh_key:
name: "{{ ssh_key_name }}"
public_key: "{{ generated_ssh_key.ssh_public_key }}"
state: present
- name: Create molecule instance(s)
hcloud_server:
name: "{{ item.name }}"
server_type: "{{ item.server_type }}"
ssh_keys:
- "{{ ssh_key_name }}"
image: "{{ item.image }}"
location: "{{ item.location | default(omit) }}"
datacenter: "{{ item.datacenter | default(omit) }}"
user_data: "{{ item.user_data | default(omit) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: present
register: server
loop: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0
- name: Wait for instance(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- name: Create volume(s)
hcloud_volume:
name: "{{ item.name }}"
server: "{{ item.name }}"
location: "{{ item.location | default(omit) }}"
size: "{{ item.volume_size | default(10) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "present"
loop: "{{ molecule_yml.platforms }}"
when: item.volume | default(False) | bool
register: volumes
async: 7200
poll: 0
- name: Wait for volume(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
# Mandatory configuration for Molecule to function.
- name: Populate instance config dict
set_fact:
instance_conf_dict:
{
"instance": "{{ item.hcloud_server.name }}",
"ssh_key_name": "{{ ssh_key_name }}",
"address": "{{ item.hcloud_server.ipv4_address }}",
"user": "{{ ssh_user }}",
"port": "{{ ssh_port }}",
"identity_file": "{{ ssh_path }}",
"volume": "{{ item.item.item.volume | default(False) | bool }}",
}
loop: "{{ hetzner_jobs.results }}"
register: instance_config_dict
when: server.changed | bool
- name: Convert instance config dict to a list
set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
when: server.changed | bool
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool
- name: Wait for SSH
wait_for:
port: "{{ ssh_port }}"
host: "{{ item.address }}"
search_regex: SSH
delay: 10
loop: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
- name: Wait for VM to settle down
pause:
seconds: 30

View File

@ -0,0 +1,78 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
tasks:
- name: Check existing instance config file
stat:
path: "{{ molecule_instance_config }}"
register: cfg
- name: Populate the instance config
set_fact:
instance_conf: "{{ (lookup('file', molecule_instance_config) | from_yaml) if cfg.stat.exists else [] }}"
- name: Destroy molecule instance(s)
hcloud_server:
name: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: absent
register: server
loop: "{{ instance_conf }}"
async: 7200
poll: 0
- name: Wait for instance(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- pause:
seconds: 5
- name: Destroy volume(s)
hcloud_volume:
name: "{{ item.instance }}"
server: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "absent"
register: volumes
loop: "{{ instance_conf }}"
when: item.volume | default(False) | bool
async: 7200
poll: 0
- name: Wait for volume(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
- name: Remove registered SSH key
hcloud_ssh_key:
name: "{{ instance_conf[0].ssh_key_name }}"
state: absent
when: (instance_conf | default([])) | length > 0
# Mandatory configuration for Molecule to function.
- name: Populate instance config
set_fact:
instance_conf: {}
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool

View File

@ -9,8 +9,8 @@ dependency:
driver: driver:
name: delegated name: delegated
platforms: platforms:
- name: rocky9-docker-engine - name: rocky8-docker-engine
image: rocky-9 image: rocky-8
server_type: cx11 server_type: cx11
lint: | lint: |
/usr/local/bin/flake8 /usr/local/bin/flake8

View File

@ -0,0 +1,15 @@
---
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Bootstrap python for Ansible
raw: |
command -v python3 python || (
(test -e /usr/bin/dnf && sudo dnf install -y python3) ||
(test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
(test -e /usr/bin/yum && sudo yum -y -qq install python3) ||
echo "Warning: Python not boostrapped due to unknown platform."
)
become: true
changed_when: false

View File

@ -0,0 +1,18 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
def test_docker_is_installed(host):
docker = host.package("docker")
assert docker.is_installed
def test_docker_running_and_enabled(host):
docker = host.service("docker")
assert docker.is_running
assert docker.is_enabled

View File

@ -7,6 +7,21 @@
notify: __docker_restart notify: __docker_restart
when: dockerengine_docker_group_enabled | bool when: dockerengine_docker_group_enabled | bool
- name: Deploy config files to setup environment
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: 0644
loop:
- { src: 'etc/sysconfig/docker.j2', dest: '/etc/sysconfig/{{ dockerengine_service }}' }
- { src: 'etc/sysconfig/docker-storage-setup.j2', dest: '/etc/sysconfig/{{ dockerengine_service }}-storage-setup' }
- { src: 'etc/containers/registries.conf.j2', dest: '/etc/containers/registries.conf' }
loop_control:
label: "{{ item.dest }}"
notify: __docker_restart
- name: Add namespace group - name: Add namespace group
group: group:
name: "{{ dockerengine_nsremap_user }}" name: "{{ dockerengine_nsremap_user }}"
@ -36,57 +51,12 @@
- /etc/subuid - /etc/subuid
- /etc/subgid - /etc/subgid
- name: Create required directories
loop:
- name: /etc/systemd/system/docker.service.d
mode: "0755"
- name: /etc/docker
mode: "0755"
loop_control:
label: "{{ item.name }}"
file:
path: "{{ item.name }}"
state: directory
mode: "{{ item.mode }}"
- name: Write environment file
template:
src: etc/sysconfig/docker.j2
dest: /etc/sysconfig/docker
mode: 0600
notify: __docker_restart
- name: Write service override.conf
template:
src: etc/systemd/system/docker.service.d/override.conf.j2
dest: /etc/systemd/system/docker.service.d/override.conf
mode: 0644
notify: __docker_restart
- name: Deploy daemon config
copy:
content: "{{ (dockerengine_daemon_config | combine(dockerengine_daemon_config_extra)) | to_nice_json }}"
dest: /etc/docker/daemon.json
mode: 0600
notify: __docker_restart
- name: Ensure docker engine is up and running - name: Ensure docker engine is up and running
service: service:
name: "{{ dockerengine_service }}" name: "{{ dockerengine_service }}"
enabled: True enabled: True
state: started state: started
- name: Handle registry logins
docker_login:
registry: "{{ item.url | default(omit) }}"
username: "{{ item.username }}"
password: "{{ item.password }}"
reauthorize: "{{ item.reauthorize | default(False) }}"
state: '{{ item.state | default("present") }}'
loop: "{{ dockerengine_registries }}"
loop_control:
label: "{{ item.url | default('DockerHub') }}"
- name: Create docker networks - name: Create docker networks
docker_network: docker_network:
name: "{{ item.name }}" name: "{{ item.name }}"

View File

@ -1,15 +1,5 @@
--- ---
- block: - block:
- name: Add Docker CE repository
yum_repository:
name: "docker-ce"
file: "Docker-CE"
description: "Docker CE Stable"
baseurl: "https://download.docker.com/linux/centos/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/stable"
gpgcheck: yes
enabled: yes
gpgkey: "https://download.docker.com/linux/rhel/gpg"
- name: Install dependencies - name: Install dependencies
package: package:
name: "{{ item }}" name: "{{ item }}"
@ -20,7 +10,7 @@
pip: pip:
name: "{{ item }}" name: "{{ item }}"
virtualenv: /opt/python2/ansible-deps virtualenv: /opt/python2/ansible-deps
loop: "{{ dockerengine_ansible_deps }}" loop: "{{ __docker_ansible_deps }}"
- name: Add docker-compose wrapper - name: Add docker-compose wrapper
template: template:
@ -30,14 +20,6 @@
group: root group: root
mode: 0755 mode: 0755
- name: Ensure to remove old docker packages
package:
name:
- docker
- docker-common
- docker-engine
state: absent
- name: Install packages - name: Install packages
package: package:
name: "{{ item }}" name: "{{ item }}"

View File

@ -0,0 +1,27 @@
{{ ansible_managed | comment }}
# This is a system-wide configuration file used to
# keep track of registries for various container backends.
# It adheres to TOML format and does not support recursive
# lists of registries.
# The default location for this configuration file is /etc/containers/registries.conf.
# The only valid categories are: 'registries.search', 'registries.insecure',
# and 'registries.block'.
[registries.search]
#registries = ['registry.access.redhat.com']
registries = [{{ dockerengine_secure_registries | xoxys.general.wrap | join(',') }}]
# If you need to access insecure registries, add the registry's fully-qualified name.
# An insecure registry is one that does not have a valid SSL certificate or only does HTTP.
[registries.insecure]
registries = [{{ dockerengine_insecure_registries | xoxys.general.wrap | join(',') }}]
# If you need to block pull access from a registry, uncomment the section below
# and add the registries fully-qualified name.
#
# Docker only
[registries.block]
registries = [{{ dockerengine_block_registries | xoxys.general.wrap | join(',') }}]

View File

@ -0,0 +1,10 @@
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
STORAGE_DRIVER=overlay2
{% if dockerengine_storage_pvs is defined %}
DEVS={{ dockerengine_storage_pvs }}
CONTAINER_ROOT_LV_NAME={{ dockerengine_storage_lv }}
CONTAINER_ROOT_LV_SIZE={{ dockerengine_storage_size }}
CONTAINER_ROOT_LV_MOUNT_PATH={{ dockerengine_base_dir }}
VG={{ dockerengine_storage_vg }}
{% endif %}

View File

@ -1,6 +1,33 @@
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }} {{ ansible_managed | comment }}
OPTIONS='{{'--userns-remap=' + dockerengine_nsremap_user + ':' + dockerengine_nsremap_user if dockerengine_usernamespace_enabled | bool else '' }}' # Modify these options if you want to change the way the docker daemon runs
OPTIONS='{{ dockerengine_cli_options | xoxys.general.prefix | join(' ') }}{{ ' --userns-remap='+dockerengine_nsremap_user+':'+dockerengine_nsremap_user if dockerengine_usernamespace_enabled | bool else '' }}'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# from the atomic-registries package.
#
# On an SELinux system, if you remove the --selinux-enabled option, you
# also need to turn on the docker_transition_unconfined boolean.
# setsebool -P docker_transition_unconfined 1
# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp
# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false
# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
# Proxy settings # Proxy settings
{% if dockerengine_http_proxy is defined %} {% if dockerengine_http_proxy is defined %}

View File

@ -1,12 +0,0 @@
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
{% if dockerengine_service_override_unit is defined %}
[Unit]
{{ dockerengine_service_override_unit }}
{% endif %}
[Service]
EnvironmentFile=-/etc/sysconfig/docker
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// \
--containerd=/run/containerd/containerd.sock \
$OPTIONS

5
vars/main.yml Normal file
View File

@ -0,0 +1,5 @@
---
__docker_ansible_deps:
- cryptography~=2.0
- docker-compose~=1.24.0
- docker