found a better way to install repo and packages using core roles

This commit is contained in:
Bertrand Lanson 2023-04-05 22:37:40 +02:00
parent b9fc61e4de
commit 4b33d2fe5d
11 changed files with 83 additions and 56 deletions

View File

@ -2,7 +2,6 @@
# defaults file for install_docker
install_docker_edition: ce # can be ce or ee (community or enterprise)
install_docker_compose: false
install_docker_version: latest
install_docker_compose_version: latest
install_docker_start_service: true
install_docker_python_packages: true

View File

@ -1,53 +1,26 @@
---
# meta file for install_docker
galaxy_info:
author: your name
namespace: ednxzu
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
namespace: 'ednxzu'
role_name: 'install_docker'
author: 'Bertrand Lanson'
description: 'Install and configure docker for debian-based distros.'
license: 'license (BSD, MIT)'
min_ansible_version: '2.10'
platforms:
- name: Ubuntu
versions:
- focal
- jammy
- name: Debian
versions:
- bullseye
galaxy_tags:
- 'ubuntu'
- 'debian'
- 'docker'
- 'container'
- 'compose'
- 'containerd'
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

5
meta/requirements.yml Normal file
View File

@ -0,0 +1,5 @@
---
# meta file for install_docker
roles:
- name: ednxzu.manage_repositories
- name: ednxzu.manage_apt_packages

View File

@ -0,0 +1,3 @@
roles:
- name: ednxzu.manage_repositories
- name: ednxzu.manage_apt_packages

7
tasks/install.yml Normal file
View File

@ -0,0 +1,7 @@
---
# task/install file for install_docker
- name: "Install docker packages"
ansible.builtin.include_role:
name: ednxzu.manage_apt_packages
vars:
manage_apt_packages_list: "{{ install_docker_packages }}"

View File

@ -1,2 +1,10 @@
---
# task/main file for install_docker
- name: "Import prerequisites.yml"
ansible.builtin.include_tasks: prerequisites.yml
- name: "Import install.yml"
ansible.builtin.include_tasks: install.yml
- name: "Import configure.yml"
ansible.builtin.include_tasks: configure.yml

9
tasks/prerequisites.yml Normal file
View File

@ -0,0 +1,9 @@
---
# task/prerequisites file for install_docker
- name: "Configure docker repository"
ansible.builtin.include_role:
name: ednxzu.manage_repositories
vars:
manage_repositories_enable_default_repo: false
manage_repositories_enable_custom_repo: true
manage_repositories_custom_repo: "{{ install_docker_repository }}"

View File

@ -1,2 +0,0 @@
---
# task/install file for install_docker

View File

@ -1,2 +1,29 @@
---
# vars file for install_docker
install_docker_packages:
- name: "docker-{{ install_docker_edition }}"
version: latest
state: present
- name: "docker-{{ install_docker_edition }}-cli"
version: latest
state: present
- name: "docker-{{ install_docker_edition }}-rootless-extras"
version: latest
state: present
- name: "containerd.io"
version: latest
state: present
install_docker_compose_packages:
- name:
version:
state: "{{ 'present' if install_docker_compose else 'absent' }}"
install_docker_repository:
- uri: "https://download.docker.com/linux/{{ ansible_distribution|lower }}"
gpg_key: "https://download.docker.com/linux/{{ ansible_distribution|lower }}/gpg"
comments: "ubuntu docker repository"
type: "deb"
suites: "{{ ansible_distribution_release }}"
components: "stable"
filename: "docker"

View File

@ -1,2 +0,0 @@
---
# task/prerequisites file for install_docker