Added install role to manage repositories
This commit is contained in:
parent
426101f774
commit
50259ba5ca
10 changed files with 103 additions and 14 deletions
|
@ -5,7 +5,7 @@
|
|||
namespace: linuxhelp
|
||||
|
||||
# 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
|
||||
version: 1.0.0
|
||||
|
@ -21,7 +21,7 @@ authors:
|
|||
|
||||
### OPTIONAL but strongly recommended
|
||||
# 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
|
||||
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
|
||||
|
|
|
@ -6,15 +6,15 @@ collections: [ 'debops.debops' ]
|
|||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
|
||||
author: 'Eric Renfro'
|
||||
description: 'Install and Configure Consul'
|
||||
company: 'Linux-Help'
|
||||
license: 'GPL-3.0-or-later'
|
||||
min_ansible_version: '2.9.0'
|
||||
min_ansible_version: '2.8'
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- stretch
|
||||
- buster
|
||||
- bullseye
|
||||
- name: Ubuntu
|
||||
|
@ -22,6 +22,7 @@ galaxy_info:
|
|||
- bionic
|
||||
- focal
|
||||
galaxy_tags:
|
||||
- hashicorp
|
||||
- debops
|
||||
- system
|
||||
- monitoring
|
||||
|
|
|
@ -2,13 +2,8 @@
|
|||
- import_role:
|
||||
name: 'secret'
|
||||
|
||||
- name: APT Repository key
|
||||
ansible.builtin.apt_key:
|
||||
url: https://apt.releases.hashicorp.com/gpg
|
||||
state: present
|
||||
|
||||
- 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
|
||||
- name: Install Consul binary
|
||||
include_role:
|
||||
name: install
|
||||
vars:
|
||||
components: [consul]
|
||||
|
|
6
roles/install/defaults/main.yml
Normal file
6
roles/install/defaults/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
os: unknown
|
||||
dist: unknown
|
||||
|
||||
components:
|
||||
- consul
|
24
roles/install/meta/main.yml
Normal file
24
roles/install/meta/main.yml
Normal 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
|
48
roles/install/tasks/apt/prepare.yml
Normal file
48
roles/install/tasks/apt/prepare.yml
Normal 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
|
6
roles/install/tasks/main.yml
Normal file
6
roles/install/tasks/main.yml
Normal 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:
|
3
roles/install/tasks/repositories.yml
Normal file
3
roles/install/tasks/repositories.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- name: Prepare package repositories
|
||||
include_tasks: "{{ ansible_pkg_mgr }}/prepare.yml"
|
3
roles/install/vars/Debian.yml
Normal file
3
roles/install/vars/Debian.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
os: debian
|
||||
dist: '{{ ansible_distribution_release }}'
|
3
roles/install/vars/Ubuntu.yml
Normal file
3
roles/install/vars/Ubuntu.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
os: ubuntu
|
||||
dist: '{{ ansible_distribution_release }}'
|
Loading…
Reference in a new issue