GithubHelp home page GithubHelp logo

robertdebock / ansible-role-docker_ce Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 7.0 267 KB

Install and configure Docker CE on your system.

Home Page: https://robertdebock.nl/

License: Apache License 2.0

dockerce docker ansible molecule tox playbook

ansible-role-docker_ce's Introduction

Install and configure Docker CE on your system.

GitHub GitLab Downloads Version
github gitlab downloads Version

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true

  roles:
    - role: robertdebock.docker_ce
      docker_ce_privileged_users:
        - woody
        - buzz

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: robertdebock.bootstrap
    - role: robertdebock.epel
    - role: robertdebock.buildtools
    - role: robertdebock.python_pip
    - role: robertdebock.core_dependencies

  tasks:
    - name: Create test case users
      ansible.builtin.user:
        name: "{{ user }}"
      loop:
        - woody
        - buzz
      loop_control:
        loop_var: user

Also see a full explanation and example on how to use these roles.

The default values for the variables are set in defaults/main.yml:

---
# defaults file for docker_ce

# Add users to the privileged docker group. For example:
# docker_ce_privileged_users:
#  - UserA
#  - UserB
docker_ce_privileged_users: []

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab
robertdebock.bootstrap Build Status GitHub Build Status GitLab
robertdebock.buildtools Build Status GitHub Build Status GitLab
robertdebock.core_dependencies Build Status GitHub Build Status GitLab
robertdebock.epel Build Status GitHub Build Status GitLab
robertdebock.python_pip Build Status GitHub Build Status GitLab

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles: dependencies

This role has been tested on these container images:

container tags
Debian bullseye
EL 8, 9
Fedora 38, 39
Ubuntu all

The minimum version of Ansible required is 2.12, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub.

Apache-2.0.

robertdebock

Please consider sponsoring me.

ansible-role-docker_ce's People

Contributors

fzarifian avatar gotmax23 avatar jellevandehaterd avatar philippwaller avatar robert-de-bock avatar robertdebock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ansible-role-docker_ce's Issues

Option to install docker-compose

Is your feature request related to a problem? Please describe.
Having installed docker, I either have to manually install docker-compose or pass it as a parameter to python_pip role.

Describe the solution you'd like
A task to install docker-compose with pip; the task can be controlled by a default variable (default vaule of false). Installing with pip will give you the latest stable version.

Describe alternatives you've considered
You could pass docker-compose as a parameter to python_pip role. However, it would make logical sense to add it to this role instead.

Additional context
N/A

docker_ce does not support alpine linux

Describe the bug
meta/main.yml (and therefore the ansible galaxy: https://galaxy.ansible.com/robertdebock/docker_ce) clearly states that all versions of alpine linux are supported -- but none are.

To Reproduce
run this playbook on a alpine host:

---
- hosts: alpine-host

  roles:
  - role: robertdebock.docker_ce

Expected behavior
docker-ce is installed after running ansible
Error
an assertion checking the distribution version fails:
Note that text enclosed in < > was put in by me and should be handled as a placeholder.

TASK [robertdebock.docker_ce : test veriables and environment] ********************************************************************************************************************************
fatal: [<hostname>]: FAILED! => {
    "assertion": "( ansible_distribution == \"Ubuntu\" and ( ansible_distribution_version == \"18.10\" or ansible_distribution_version == \"18.04\" or ansible_distribution_version == \"16.04\" ) ) or ( ansible_distribution == \"Debian\" and ( ansible_distribution_major_version == \"9\" or ansible_distribution_major_version == \"10\" ) ) or ( ansible_distribution == \"Fedora\" and ( ansible_distribution_major_version == \"28\" or ansible_distribution_major_version == \"29\" ) ) or ( ansible_distribution == \"CentOS\" and ( ansible_distribution_major_version == \"7\" ) )",
    "changed": false,
    "evaluated_to": false,
    "msg": "Assertion failed"
}
        to retry, use: --limit @/<...>/ansible/site.retry

PLAY RECAP ************************************************************************************************************************************************************************************
<hostname> : ok=1    changed=0    unreachable=0    failed=1   

docker-compose is installed but it runs in error on bento/centos-7 (7.8) vagrant box.

Hi,
It seems that there is some version mismatch between python docker-compose etc, it seems to be an error with python 2.7 which is no longer supported?
An yum install of docker-compose seems to work ok, because it will download and install python 3.6.

I tried your roles and it seems docker-compose is installed but won't run:
[vagrant@hdp jenkins-sa]$ docker-compose up
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 7, in
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 14, in
import docker.errors
File "/usr/lib/python2.7/site-packages/docker/init.py", line 2, in
from .api import APIClient
File "/usr/lib/python2.7/site-packages/docker/api/init.py", line 2, in
from .client import APIClient
File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 5, in
import requests
File "/usr/lib/python2.7/site-packages/requests/init.py", line 58, in
from . import utils
File "/usr/lib/python2.7/site-packages/requests/utils.py", line 32, in
from .exceptions import InvalidURL
File "/usr/lib/python2.7/site-packages/requests/exceptions.py", line 10, in
from urllib3.exceptions import HTTPError as BaseHTTPError
File "/usr/lib/python2.7/site-packages/urllib3/init.py", line 10, in
from .connectionpool import (
File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 31, in
from .connection import (
File "/usr/lib/python2.7/site-packages/urllib3/connection.py", line 45, in
from .util.ssl_ import (
File "/usr/lib/python2.7/site-packages/urllib3/util/init.py", line 5, in
from .request import make_headers
File "/usr/lib/python2.7/site-packages/urllib3/util/request.py", line 5, in
from ..exceptions import UnrewindableBodyError
ImportError: cannot import name UnrewindableBodyError

No setuptools found in remote host

Describe the bug
TASK [robertdebock.docker_ce : install docker pip packages] *********************************************************************************************************************************************************************************
FAILED - RETRYING: install docker pip packages (3 retries left).
FAILED - RETRYING: install docker pip packages (2 retries left).
FAILED - RETRYING: install docker pip packages (1 retries left).
fatal: [ubuntu-s-1vcpu-2gb-fra1-01]: FAILED! => {"attempts": 3, "changed": false, "msg": "No setuptools found in remote host, please install it first."}

To Reproduce
Steps to reproduce the behavior:

  • name: bootstrap all hosts
    hosts: linux
    become: yes
    gather_facts: no

    roles:

    • role: robertdebock.docker_ce
      ansible-playbook playbook.yaml -u root
      ubuntu 18.04 on digital ocean

Expected behavior
A clear and concise description of what you expected to happen.

Error
Please show the resulting error. If applicable a snippet of the playbook including the role ran with -vvv

Environment

  • Control node OS: [e.g. Debian 9]
  • Control node Ansible version: [e.g. 2.6.2]
  • Managed node OS: [e.g. CentOS 7]

Additional context
Add any other context about the problem here.

docker-ce binaries are no longer distributed for RHEL on x86_64

Bug description

the docker-ce binaries are no longer available from the official yum/dnf docker repositories for RHEL on the x86_64 architecture.

c.f. (https://docs.docker.com/engine/install/rhel/

It's working when running the playbook with -e docker_ce_dist="centos"

Playbook

- hosts: all
  gather_facts: yes
  become: yes
  vars_files:
    - vars/vault.yml
  pre_tasks:
    - name: Disable NetworkManager
      systemd:
        name: NetworkManager
        state: stopped
        enabled: no
        masked: yes
      when: networkmanager_enabled is defined and not networkmanager_enabled
  roles:
    - role: robertdebock.core_dependencies
    - role: robertdebock.common
    - role: robertdebock.selinux
    - role: robertdebock.buildtools
    - role: robertdebock.cron
    - role: robertdebock.ntp
    - role: robertdebock.epel
    - role: itigoag.packages
      tags: packages
    - role: freeipa-client
      when: "'freeipa_clients' in group_names"
      tags: auth
    - role: stackhpc.libvirt-host
      when: "'libvirt_hosts' in group_names"
      tags: virt
    - role: robertdebock.python_pip
      when: "'docker_hosts' in group_names"
    - role: robertdebock.docker_ce
      when: "'docker_hosts' in group_names"
      tags: container
    - role: common
    - role: tessares_server
  tasks:
    - name: add user to libvirt group
      user:
        name: "{{ item.name }}"
        groups: libvirt
        append: yes
      loop: "{{ libvirt_users|default([])|union(administrators)|list|unique }}"
      when: "'libvirt_hosts' in group_names"
      tags: virt

Output

TASK [robertdebock.docker_ce : install docker_ce packages] *************************************************************************************************************************************************************************************************************************
fatal: [openstack12]: FAILED! => {"changed": false, "msg": "Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried", "rc": 1, "results": []}

Environment

  • Control node OS: Ubuntu 20.04.2 LTS
  • Control node Ansible version: ansible 4.3.0 (ansible-core-2.11.3)
  • Managed node OS: Rocky Linux 8.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.