Skip to content

Commit

Permalink
Merge pull request #12 from crumohr/master
Browse files Browse the repository at this point in the history
Add dependencies for configuration by ansible
  • Loading branch information
brianshumate authored Nov 10, 2016
2 parents e78e4ef + f39ca22 commit 9a37675
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 35 deletions.
9 changes: 9 additions & 0 deletions tasks/client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

- name: Install dependencies for configuration by ansible (1/2)
apt: name={{ item }} state=installed
with_items:
- python-pip
- python-setuptools
- name: Install dependencies for configuration by ansible (2/2)
pip: executable=pip name=python-consul
48 changes: 16 additions & 32 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,19 @@
msg: "If iptables is enabled recursors are required"
when: consul_iptables_enable and consul_recursors|length == 0

- name: Create cluster groupings
group_by: "key={{ consul_node_role }}"

- group_by: "key=os_{{ ansible_os_family }}"

- name: Add Consul user
user: "name=consul comment='Consul user' uid=1042 group=bin"

- name: CentOS tasks
include: CentOS.yml
when: ansible_distribution == "CentOS"

- name: Debian tasks
include: Debian.yml
when: ansible_distribution == "Debian"

- name: Red Hat tasks
include: RedHat.yml
when: ansible_distribution == "RedHat"
- name: Install specified packages
include: "{{ ansible_distribution }}.yml"

- name: Ubuntu tasks
include: Ubuntu.yml
when: ansible_distribution == "Ubuntu"

- name: Generate gossip encryption key
shell: "PATH=/usr/local/bin:$PATH consul keygen"
register: consul_raw_key
run_once: true
- block:
- name: Generate gossip encryption key
shell: "PATH=/usr/local/bin:$PATH consul keygen"
register: consul_keygen
run_once: true
- name: Save encryption key
set_fact: consul_raw_key={{ consul_keygen.stdout }}
when: consul_raw_key is not defined

- name: Directories
Expand All @@ -88,8 +73,7 @@
- name: Server configuration
template: src=server_config.json.j2 dest={{ consul_config_path }}/server/config.json

- name: ACL configuration
include: ../tasks/acl.yml
- include: ../tasks/acl.yml
when: consul_acl_enable

- name: Atlas configuration
Expand Down Expand Up @@ -130,12 +114,12 @@
replace: dest=/etc/init.d/consul regexp='bootstrap' replace='server' backup=no
when: consul_node_role == "bootstrap" and not ansible_service_mgr == "systemd" and ansible_distribution_major_version|int <= 7

- name: "Enable Dnsmasq"
include: ../tasks/dnsmasq.yml
notify:
- restart dnsmasq
- include: ../tasks/dnsmasq.yml
notify: restart dnsmasq
when: consul_dnsmasq_enable

- name: "Enable iptables"
include: ../tasks/iptables.yml
- include: ../tasks/iptables.yml
when: consul_iptables_enable

- include: ../tasks/client.yml
when: consul_node_role == "client" and ansible_os_family == "Debian"
2 changes: 1 addition & 1 deletion templates/client_config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"node_name": "{{ consul_node_name }}",
"datacenter": "{{ consul_datacenter }}",
"data_dir": "{{ consul_data_path }}",
"encrypt": "{{ consul_raw_key['stdout']}}",
"encrypt": "{{ consul_raw_key }}",
"log_level": "{{ consul_log_level }}",
"enable_syslog": {{ consul_syslog_enable|lower }},
"start_join": [ {% for host in groups[consul_group_name] -%}
Expand Down
2 changes: 1 addition & 1 deletion templates/server_bootstrap_config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"node_name": "{{ consul_node_name }}",
"datacenter": "{{ consul_datacenter }}",
"data_dir": "{{ consul_data_path }}",
"encrypt": "{{ consul_raw_key['stdout']}}",
"encrypt": "{{ consul_raw_key }}",
"log_level": "{{ consul_log_level }}",
"enable_syslog": {{ consul_syslog_enable|lower }},
"domain": "{{ consul_domain }}",
Expand Down
2 changes: 1 addition & 1 deletion templates/server_config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"node_name": "{{ consul_node_name }}",
"datacenter": "{{ consul_datacenter }}",
"data_dir": "{{ consul_data_path }}",
"encrypt": "{{ consul_raw_key['stdout']}}",
"encrypt": "{{ consul_raw_key }}",
"log_level": "{{ consul_log_level }}",
"enable_syslog": {{ consul_syslog_enable|lower }},
"start_join": [ "{{ consul_bootstrap_address }}" ],
Expand Down

0 comments on commit 9a37675

Please sign in to comment.