Skip to content

Commit

Permalink
Numerous updates:
Browse files Browse the repository at this point in the history
- Keep gossip encryption in main tasks until we sort cross play var
- Compact YAML style for all tasks
- Fix task items, shorten timeouts
- Update documentation
  • Loading branch information
brianshumate committed Feb 23, 2017
1 parent cb0ab1b commit dbd8e3e
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 63 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,10 @@
## v1.9.1

- Split gossip encryption out into separate task file

## v1.9.2

- Keep gossip encryption in main tasks until we sort cross play var
- Compact YAML style for all tasks
- Fix task items, shorten timeouts
- Update documentation
17 changes: 12 additions & 5 deletions tasks/acl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
register: consul_acl_master_token_keygen
run_once: true
- name: Save ACL master yoken
set_fact: consul_acl_master_token={{ consul_acl_master_token_keygen.stdout }}
set_fact:
consul_acl_master_token: "{{ consul_acl_master_token_keygen.stdout }}"
when: consul_acl_master_token is not defined and not bootstrap_marker.stat.exists

- name: Display ACL Master Token
Expand All @@ -21,16 +22,20 @@
register: consul_acl_replication_token_keygen
run_once: true
- name: Save ACL replication yoken
set_fact: consul_acl_replication_token={{ consul_acl_replication_token_keygen.stdout }}
set_fact:
consul_acl_replication_token: "{{ consul_acl_replication_token_keygen.stdout }}"
when: (consul_acl_replication_token is not defined or consul_acl_replication_token == '') and not bootstrap_marker.stat.exists

- name: Display ACL Replication Token
debug: msg="{{ consul_acl_replication_token }}"
debug:
msg: "{{ consul_acl_replication_token }}"
run_once: True
when: consul_acl_replication_token_display

- name: ACL bootstrap configuration
template: src=config_acl.json.j2 dest={{ consul_config_path }}/{{ item }}/config_acl.json
template:
src:config_acl.json.j2
dest: "{{ consul_config_path }}/{{ item }}/config_acl.json"
with_items:
- bootstrap
- client
Expand All @@ -39,7 +44,9 @@
- restart consul

- name: ACL policy configuration
template: src=config_acl_policy.hcl.j2 dest={{ consul_config_path }}/{{ item }}/config_acl_policy.hcl
template:
src: config_acl_policy.hcl.j2
dest: "{{ consul_config_path }}/{{ item }}/config_acl_policy.hcl"
with_items:
- bootstrap
- client
Expand Down
4 changes: 3 additions & 1 deletion tasks/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# File: tasks/client.yml - Ansible dependencies for Consul

- name: Install dependencies for configuration by ansible (1/2)
apt: name={{ item }} state=installed
apt:
name: "{{ item }}"
state: installed
with_items:
- python-pip
- python-setuptools
Expand Down
19 changes: 15 additions & 4 deletions tasks/dnsmasq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,30 @@
# File: tasks/dnsmasq.yml - Dnsmasq tasks for Consul

- name: Dnsmasq package
yum: name=dnsmasq state=present
yum:
name: dnsmasq
state: present
when: ansible_os_family == "RedHat"
tags: dnsmasq,installation

- name: Dnsmasq package
apt: name=dnsmasq state=present
apt:
name: dnsmasq
state: present
when: ansible_os_family == "Debian"
tags: dnsmasq,installation

- name: Stop Dnsmasq
service: name=dnsmasq state=stopped
service:
name: dnsmasq
state: stopped

- name: "Dnsmasq setup"
copy: src=../files/dnsmasq-10-consul dest=/etc/dnsmasq.d/10-consul owner=root group=root mode=0644
copy:
src: ../files/dnsmasq-10-consul
dest: /etc/dnsmasq.d/10-consul
owner: root
group: root
mode: 0644
notify: restart dnsmasq
tags: dnsmasq
36 changes: 28 additions & 8 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@
# File: tasks/install.yml - package installation tasks for Consul

- name: OS packages
package: "name={{ item }} state=present"
package:
name: "{{ item }}"
state: present
with_items: "{{ consul_os_packages }}"
tags: installation

- name: Check Consul package checksum file
become: no
connection: local
stat: "path={{ role_path }}/files/consul_{{ consul_version }}_SHA256SUMS"
stat:
path: "{{ role_path }}/files/consul_{{ consul_version }}_SHA256SUMS"
run_once: true
register: consul_checksum

- name: Get Consul package checksum file
become: no
connection: local
get_url: "url={{ consul_checksum_file_url }} dest={{ role_path }}/files/consul_{{ consul_version }}_SHA256SUMS"
get_url:
url: "{{ consul_checksum_file_url }}"
dest: "{{ role_path }}/files/consul_{{ consul_version }}_SHA256SUMS"
run_once: true
tags: installation
when: consul_checksum.stat.exists == False
Expand All @@ -32,33 +37,48 @@
- name: Check Consul package file
become: no
connection: local
stat: "path={{ role_path }}/files/{{ consul_pkg }}"
stat:
path: "{{ role_path }}/files/{{ consul_pkg }}"
run_once: true
register: consul_package

- name: Download Consul
become: no
connection: local
get_url: "url={{ consul_zip_url }} dest={{ role_path }}/files/{{ consul_pkg }} checksum=sha256:{{ consul_sha256.stdout.split(' ')|first }} timeout=42"
get_url:
url: "{{ consul_zip_url }}"
dest: "{{ role_path }}/files/{{ consul_pkg }}"
checksum: "sha256:{{ consul_sha256.stdout.split(' ')|first }}"
timeout: 42
run_once: true
tags: installation
when: consul_package.stat.exists == False

- name: Unarchive Consul
become: no
connection: local
unarchive: "src={{ role_path }}/files/{{ consul_pkg }} dest={{ role_path }}/files/ creates={{ role_path }}/files/consul"
unarchive:
src: "{{ role_path }}/files/{{ consul_pkg }}"
dest: "{{ role_path }}/files/"
creates: "{{ role_path }}/files/consul"
run_once: true
tags: installation

- name: Install Consul
copy: "src={{ role_path }}/files/consul dest=/usr/local/bin/ owner={{ consul_user }} group={{ consul_group }} mode=0755"
copy:
src: "{{ role_path }}/files/consul"
dest: /usr/local/bin/
owner: "{{ consul_user }}"
group: "{{ consul_group }}"
mode: 0755
tags: installation

- name: Cleanup
become: no
connection: local
file: "path={{ item }} state=absent"
file:
path: "{{ item }}"
state: absent
with_fileglob: "{{ role_path }}/files/consul"
run_once: true
tags: installation
51 changes: 41 additions & 10 deletions tasks/iptables.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
---
# File: tasks/iptables.yml - iptables tasks for Consul

- name: install iptables
apt: name=iptables
- name: Install iptables
apt:
name: iptables

- name: redirect local DNS (1/4)
iptables: table=nat chain=PREROUTING protocol=udp match=udp destination_port=53 jump=REDIRECT to_ports=8600
- name: Redirect local DNS (1/4)
iptables:
table: nat
chain: PREROUTING
protocol: udp
match: udp
destination_port: 53
jump: REDIRECT
to_ports: 8600

- name: redirect local DNS (2/4)
iptables: table=nat chain=PREROUTING protocol=tcp match=tcp destination_port=53 jump=REDIRECT to_ports=8600
- name: Redirect local DNS (2/4)
iptables:
table: nat
chain: PREROUTING
protocol: tcp
match: tcp
destination_port: 53
jump: REDIRECT
to_ports: 8600

- name: redirect local DNS (3/4)
iptables: table=nat chain=OUTPUT protocol=udp match=udp destination_port=53 jump=REDIRECT to_ports=8600 destination=localhost
- name: Redirect local DNS (3/4)
iptables:
table: nat
chain: OUTPUT
protocol: udp
match: udp
destination_port: 53
jump: REDIRECT
to_ports: 8600
destination: localhost

- name: redirect local DNS (4/4)
iptables: table=nat chain=OUTPUT protocol=tcp match=tcp destination_port=53 jump=REDIRECT to_ports=8600 destination=localhost
- name: Redirect local DNS (4/4)
iptables:
table: nat
chain: OUTPUT
protocol: tcp
match: tcp
destination_port: 53
jump: REDIRECT
to_ports: 8600
destination: localhost

Loading

0 comments on commit dbd8e3e

Please sign in to comment.