aboutsummaryrefslogtreecommitdiffstats
path: root/fdio.infra.ansible/roles/consul/tasks
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2021-04-08 10:44:18 +0000
committerPeter Mikus <pmikus@cisco.com>2021-04-08 11:17:15 +0000
commitdf5672b3d9c29b51397f4770eb992c9f3f3955ce (patch)
treeadb4cf36c9b680ebbc44c953391a0d21b986d6b7 /fdio.infra.ansible/roles/consul/tasks
parent8018da98e0f362bc69fc9600fac222a86fd46b5e (diff)
Ansible git move
+ Better accessibility + Compliant with fdio.infra._function_ - function [pxe|terraform|ansible|vagrant] + dill==0.3.3 also applied on TBs - ci-man to follow today - Docs to be updated in separate patch Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: Iff9eaa29d63044188cc8160db2d9b44b7635782a
Diffstat (limited to 'fdio.infra.ansible/roles/consul/tasks')
-rw-r--r--fdio.infra.ansible/roles/consul/tasks/main.yaml182
1 files changed, 182 insertions, 0 deletions
diff --git a/fdio.infra.ansible/roles/consul/tasks/main.yaml b/fdio.infra.ansible/roles/consul/tasks/main.yaml
new file mode 100644
index 0000000000..99ac52da44
--- /dev/null
+++ b/fdio.infra.ansible/roles/consul/tasks/main.yaml
@@ -0,0 +1,182 @@
+---
+# file: roles/consul/tasks/main.yaml
+
+- name: Inst - Update Package Cache (APT)
+ apt:
+ update_cache: yes
+ cache_valid_time: 3600
+ when:
+ - ansible_distribution|lower == 'ubuntu'
+ tags:
+ - consul-inst-prerequisites
+
+- name: Inst - Prerequisites
+ package:
+ name: "{{ packages | flatten(levels=1) }}"
+ state: latest
+ tags:
+ - consul-inst-prerequisites
+
+- name: Conf - Add Consul Group
+ group:
+ name: "{{ consul_group }}"
+ state: "{{ consul_group_state }}"
+ when:
+ - consul_manage_group | bool
+ tags:
+ - consul-conf-user
+
+- name: Conf - Add Consul user
+ user:
+ name: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ groups: "{{ consul_user_groups }}"
+ state: "{{ consul_user_state }}"
+ system: true
+ when:
+ - consul_manage_user | bool
+ tags:
+ - consul-conf-user
+
+- name: Inst - Clean Consul
+ file:
+ path: "{{ consul_inst_dir }}/consul"
+ state: "absent"
+ tags:
+ - consul-inst-package
+
+- name: Inst - Download Consul
+ get_url:
+ url: "{{ consul_zip_url }}"
+ dest: "{{ consul_inst_dir }}/{{ consul_pkg }}"
+ tags:
+ - consul-inst-package
+
+- name: Inst - Unarchive Consul
+ unarchive:
+ src: "{{ consul_inst_dir }}/{{ consul_pkg }}"
+ dest: "{{ consul_inst_dir }}/"
+ creates: "{{ consul_inst_dir }}/consul"
+ remote_src: true
+ tags:
+ - consul-inst-package
+
+- name: Inst - Consul
+ copy:
+ src: "{{ consul_inst_dir }}/consul"
+ dest: "{{ consul_bin_dir }}"
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ force: true
+ mode: 0755
+ remote_src: true
+ tags:
+ - consul-inst-package
+
+- name: Conf - Create Directories "{{ consul_data_dir }}"
+ file:
+ dest: "{{ consul_data_dir }}"
+ state: directory
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ tags:
+ - consul-conf
+
+- name: Conf - Create Directories "{{ consul_ssl_dir }}"
+ file:
+ dest: "{{ consul_ssl_dir }}"
+ state: directory
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ tags:
+ - consul-conf
+
+- name: Conf - Create Config Directory
+ file:
+ dest: "{{ consul_config_dir }}"
+ state: directory
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ mode: 0755
+ tags:
+ - consul-conf
+
+- name: Conf - Nomad integration Consul Configuration
+ template:
+ src: consul.hcl.j2
+ dest: "{{ nomad_config_dir }}/consul.hcl"
+ owner: "nomad"
+ group: "nomad"
+ mode: 0644
+ when:
+ - consul_nomad_integration | bool
+ tags:
+ - consul-conf
+
+- name: Conf - Base Configuration
+ template:
+ src: base.hcl.j2
+ dest: "{{ consul_config_dir }}/base.hcl"
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ mode: 0644
+ tags:
+ - consul-conf
+
+- name: Conf - Ports Configuration
+ template:
+ src: ports.hcl.j2
+ dest: "{{ consul_config_dir }}/ports.hcl"
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ mode: 0644
+ tags:
+ - consul-conf
+
+- name: Conf - Telemetry Configuration
+ template:
+ src: telemetry.hcl.j2
+ dest: "{{ consul_config_dir }}/telemetry.hcl"
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ mode: 0644
+ tags:
+ - consul-conf
+
+- name: Conf - Services Configuration
+ template:
+ src: services.json.j2
+ dest: "{{ consul_config_dir }}/services.json"
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ mode: 0644
+ when:
+ - consul_services
+ tags:
+ - consul-conf
+
+- name: Conf - Copy Certificates And Keys
+ copy:
+ content: "{{ item.src }}"
+ dest: "{{ item.dest }}"
+ owner: "{{ consul_user }}"
+ group: "{{ consul_group }}"
+ mode: 0600
+ no_log: true
+ loop: "{{ consul_certificates | flatten(levels=1) }}"
+ tags:
+ - consul-conf
+
+- name: Conf - System.d Script
+ template:
+ src: "consul_systemd.service.j2"
+ dest: "/lib/systemd/system/consul.service"
+ owner: "root"
+ group: "root"
+ mode: 0644
+# notify:
+# - "Restart Consul"
+# - "Stop Systemd-resolved"
+# - "Restart Nomad"
+ tags:
+ - consul-conf