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

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

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

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

- name: Expose consul_bind_address as fact
  set_fact:
EKbfh's avatar
EKbfh committed
57
    consul_bind_address: "{{ consul_address }}"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
58
59
60
  when:
    - consul_address is defined
    - consul_address!='node_ip'
Aleksey Shirokih's avatar
Aleksey Shirokih committed
61
  tags:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
62
    - config
Noc User ubuntu-srv-02's avatar
Noc User ubuntu-srv-02 committed
63

64
65
66
67
68
69
70
71
72
73
74
75
#- name: Add Consul repository
#  yum_repository:
#    name: consul
#    description: consul repository
#    baseurl: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
#    enabled: "True"
#  environment:
#    http_proxy: "{{ http_proxy }}"
#    https_proxy: "{{ http_proxy }}"
#  tags:
#    - repo

76
77
78
79
80
81
82
83
84
85
#- name: Install yum-utils
#  yum:
#    name: yum-utils
#    state: present
#    update_cache: "True"
#    allow_downgrade: "True"

#- name: Add Consul repository
#  shell:
#    yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
86

Noc User ubuntu-srv-02's avatar
Noc User ubuntu-srv-02 committed
87
- name: Add Consul repository
88
89
90
91
92
  yum_repository:
    name: consul
    description: consul repository
    baseurl: https://rpm.releases.hashicorp.com/RHEL/$releasever/$basearch/stable
    enabled: "True"
93
    gpgcheck: "True"
94
    gpgkey: https://rpm.releases.hashicorp.com/gpg
Noc User ubuntu-srv-02's avatar
Noc User ubuntu-srv-02 committed
95
96
97

- name: Install Consul
  yum:
98
    name: consul-{{ consul_version_rh }}
Noc User ubuntu-srv-02's avatar
Noc User ubuntu-srv-02 committed
99
100
101
102
103
104
105
106
    state: present
    update_cache: "True"
    allow_downgrade: "True"
  tags:
    - requirements
  environment:
    http_proxy: "{{ http_proxy }}"
    https_proxy: "{{ http_proxy }}"