Added install role to manage repositories

This commit is contained in:
Eric Renfro 2022-03-01 13:33:32 -05:00
parent 426101f774
commit 50259ba5ca
Signed by: psi-jack
GPG key ID: 14977F3A50D9A5BF
10 changed files with 103 additions and 14 deletions

View file

@ -5,7 +5,7 @@
namespace: linuxhelp namespace: linuxhelp
# The name of the collection. Has the same character restrictions as 'namespace' # The name of the collection. Has the same character restrictions as 'namespace'
name: consul name: hashicorp
# The version of the collection. Must be compatible with semantic versioning # The version of the collection. Must be compatible with semantic versioning
version: 1.0.0 version: 1.0.0
@ -21,7 +21,7 @@ authors:
### OPTIONAL but strongly recommended ### OPTIONAL but strongly recommended
# A short summary description of the collection # A short summary description of the collection
description: DebOps Consul Collection description: DebOps HashiCorp Collection
# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only # Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' # accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'

View file

@ -6,15 +6,15 @@ collections: [ 'debops.debops' ]
dependencies: [] dependencies: []
galaxy_info: galaxy_info:
author: 'Eric Renfro' author: 'Eric Renfro'
description: 'Install and Configure Consul' description: 'Install and Configure Consul'
company: 'Linux-Help' company: 'Linux-Help'
license: 'GPL-3.0-or-later' license: 'GPL-3.0-or-later'
min_ansible_version: '2.9.0' min_ansible_version: '2.8'
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- stretch
- buster - buster
- bullseye - bullseye
- name: Ubuntu - name: Ubuntu
@ -22,6 +22,7 @@ galaxy_info:
- bionic - bionic
- focal - focal
galaxy_tags: galaxy_tags:
- hashicorp
- debops - debops
- system - system
- monitoring - monitoring

View file

@ -2,13 +2,8 @@
- import_role: - import_role:
name: 'secret' name: 'secret'
- name: APT Repository key - name: Install Consul binary
ansible.builtin.apt_key: include_role:
url: https://apt.releases.hashicorp.com/gpg name: install
state: present vars:
components: [consul]
- name: APT Repository Configured
ansible.builtin.apt_repository:
repo: deb [arch=amd64] https://apt.releases.hashicorp.com {{ansible_lsb.codename}} main
state: present
filename: hashicorp

View file

@ -0,0 +1,6 @@
---
os: unknown
dist: unknown
components:
- consul

View file

@ -0,0 +1,24 @@
galaxy_info:
author: Eric Renfro <psi-jack@linux-help.org>
description: Install HashiCorp components
license: GPL-3.0-or-later
min_ansible_version: 2.8
platforms:
- name: Ubuntu
versions:
- trusty
- xenial
- bionic
- disco
- name: Debian
versions:
- stretch
- buster
- bullseye
galaxy_tags:
- hashicorp
- debops
- system
- monitoring

View file

@ -0,0 +1,48 @@
---
- name: Include distro-specific vars ({{ ansible_distribution }})
include_vars: file='{{ ansible_distribution }}.yml'
- name: Update apt cache (ensure we have package index)
apt:
update_cache: true
# Updating the APT cache does not change the system so we never report a
# change here (helps keep the role idempotent).
changed_when: false
- name: Install utility packages
apt:
name:
- gnupg
- debian-archive-keyring
- apt-transport-https
state: present
- name: Fetch the apt repository key
uri:
url: https://apt.releases.hashicorp.com/gpg
force_basic_auth: true
return_content: true
register: apt_key_download
# Fetching resource into memory does not change the system at all, so we
# never report a change here (helps keep the role idempotent). And by the
# same line of reasoning, we are also safe to run in check mode (the uri
# module does not support check mode and would cause us grief when it would
# be skipped).
changed_when: false
check_mode: false
- name: Add apt key
apt_key:
data: "{{ apt_key_download.content }}"
- name: Add apt repository
apt_repository:
repo: deb [arch=amd64] https://apt.releases.hashicorp.com {{ dist }} main
filename: /etc/apt/sources.list.d/hashicorp
validate_certs: true
- name: Add apt source repository
apt_repository:
repo: deb [arch=amd64] https://apt.releases.hashicorp.com {{ dist }} main
filename: /etc/apt/sources.list.d/hashicoprp
validate_certs: true

View file

@ -0,0 +1,6 @@
---
- name: Prepare package repositories
include_tasks: repositories.yml
when: ansible_facts.os_family != "Windows" # No repo concept on Windows
# install selected packages:

View file

@ -0,0 +1,3 @@
---
- name: Prepare package repositories
include_tasks: "{{ ansible_pkg_mgr }}/prepare.yml"

View file

@ -0,0 +1,3 @@
---
os: debian
dist: '{{ ansible_distribution_release }}'

View file

@ -0,0 +1,3 @@
---
os: ubuntu
dist: '{{ ansible_distribution_release }}'