main.yml 1.2 KB
Newer Older
1
---
2
3
4
5
- name: Install CentOS consul depends
  yum:
    name: "{{ item }}"
    state: present
Aleksey Shirokih's avatar
Aleksey Shirokih committed
6
    update_cache: "True"
7
  with_items:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
8
    - python-virtualenv
9
10
11
12
13
14
  environment:
    https_proxy: "{{ http_proxy }}"
    http_proxy: "{{ http_proxy }}"
  tags:
    - requirements

Aleksey Shirokih's avatar
Aleksey Shirokih committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
- 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

- name: check firewalld state
29
30
  systemd:
    name: firewalld
Aleksey Shirokih's avatar
Aleksey Shirokih committed
31
  check_mode: "True"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
32
  register: firewalld_state
Aleksey Shirokih's avatar
Aleksey Shirokih committed
33
34
  changed_when: "False"
  ignore_errors: "True"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
35
36
37
38
39
40
41
  tags:
    - config
    - firewall

- name: Add firewall permissions for nodes
  firewalld:
    port: "{{item}}"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
42
    permanent: "True"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
43
    state: enabled
Aleksey Shirokih's avatar
Aleksey Shirokih committed
44
    immediate: "True"
45
  when: "firewalld_state.status.ActiveState == 'active'"
46
  with_items:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
47
48
49
50
51
52
53
54
55
56
57
58
    - 8300/tcp
    - 8301/tcp
    - 8301/udp
    - 8302/tcp
    - 8302/udp
    - 8500/tcp
  tags:
    - config
    - firewall

- name: Expose consul_bind_address as fact
  set_fact:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
59
    consul_bind_address: "{{consul_address}}"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
60
61
62
  when:
    - consul_address is defined
    - consul_address!='node_ip'
Aleksey Shirokih's avatar
Aleksey Shirokih committed
63
  tags:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
64
    - config