main.yml 966 Bytes
Newer Older
1
---
Aleksey Shirokih's avatar
Aleksey Shirokih committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- name: systemd script
  template:
    src: consul_systemd.service.j2
    dest: /lib/systemd/system/consul.service
    owner: root
    group: root
    mode: 0644
  tags:
    - config
  notify:
    - reload systemd
    - restart consul

# ignore erros will be even here or later
- name: check firewalld state
Aleksey Shirokih's avatar
Aleksey Shirokih committed
17
  command: systemctl is-active firewalld
Aleksey Shirokih's avatar
Aleksey Shirokih committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  register: firewalld_state
  changed_when: false
  ignore_errors: yes
  tags:
    - config
    - firewall

- name: Add firewall permissions for nodes
  firewalld:
    port: "{{item}}"
    permanent: true
    state: enabled
    immediate: true
  when: "firewalld_state.stdout == 'active'"
32
  with_items:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
33
34
35
36
37
38
39
40
41
42
43
44
    - 8300/tcp
    - 8301/tcp
    - 8301/udp
    - 8302/tcp
    - 8302/udp
    - 8500/tcp
  tags:
    - config
    - firewall

- name: Expose consul_bind_address as fact
  set_fact:
45
    consul_bind_address: "{{ansible_host}}"
46
  when: consul_address is defined and consul_address!='node_ip'
Aleksey Shirokih's avatar
Aleksey Shirokih committed
47
48
  tags:
    - config