add consul role

This commit is contained in:
2022-08-30 07:45:41 -05:00
parent 4d07232525
commit 789541a90f
8 changed files with 157 additions and 0 deletions

View File

@ -0,0 +1,18 @@
---
- name: install Hashicorp yum repo
yum_repository:
name: hashicorp
description: Hashicorp Stable - $basearch
baseurl: https://rpm.releases.hashicorp.com/RHEL/$releasever/$basearch/stable
enabled: 1
gpgcheck: 1
gpgkey: https://rpm.releases.hashicorp.com/gpg
- name: install Hashicorp (test) yum repo
yum_repository:
name: hashicorp-test
description: Hashicorp Test - $basearch
baseurl: https://rpm.releases.hashicorp.com/RHEL/$releasever/$basearch/test
enabled: 0
gpgcheck: 1
gpgkey: https://rpm.releases.hashicorp.com/gpg

View File

@ -0,0 +1,9 @@
---
- name: configure unbound forwarder
copy:
src: unbound-consul.conf
dest: "{{ unbound_conf_d_path }}/consul.conf"
owner: root
group: root
mode: "0644"
notify: reload unbound

View File

@ -0,0 +1,47 @@
---
- name: gather os specific variables
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: include os specific tasks
include_tasks: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
- name: install
package:
name: "{{ consul_package_name | default('consul') }}"
state: "{{ consul_package_state | default('present') }}"
- name: configure
template:
src: "{{ consul_config_template }}"
dest: "{{ consul_config_path }}"
owner: "{{ consul_config_owner }}"
group: "{{ consul_config_group }}"
mode: "{{ consul_config_mode }}"
notify: restart consul
- name: service
service:
name: "{{ consul_service_name | default('consul') }}"
state: "{{ consul_service_state | default('started') }}"
enabled: "{{ consul_service_enabled | default(true) }}"
- include: forward-unbound.yaml
when: consul_unbound_enabled