install.yml 1.57 KB
Newer Older
EKbfh's avatar
EKbfh committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
- name: Get Nats package checksum file
  get_url:
    url: "{{ nats_checksum_file_url }}"
    dest: "{{ nats_temp_file_checksum }}"
    validate_certs: "True"
  delegate_to: 127.0.0.1
  become: "False"
  run_once: "True"
  environment:
    https_proxy: "{{ http_proxy }}"

- name: Get Nats package checksum
  command: "grep {{ nats_pkg }} {{ nats_temp_file_checksum }}"
  register: nats_sha256
  check_mode: "False"
  delegate_to: 127.0.0.1
  become: "False"
  run_once: "True"
EKbfh's avatar
EKbfh committed
20
  changed_when: false
EKbfh's avatar
EKbfh committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

- name: Download Nats
  get_url:
    url: "{{ nats_zip_url }}"
    dest: "{{ nats_temp_file }}"
    checksum: "sha256:{{ nats_sha256.stdout.split(' ')|first }}"
    timeout: 42
    validate_certs: "True"
  delegate_to: 127.0.0.1
  become: "False"
  run_once: "True"
  environment:
    https_proxy: "{{ http_proxy }}"

- name: create Nats tmp dir
  file:
    dest: "{{ nats_temp_unarchive }}"
    state: directory
  when: not ansible_check_mode

- name: Unarchive Nats and install binary
  unarchive:
    src: "{{ nats_temp_file }}"
    dest: "{{ nats_temp_unarchive }}"
    owner: "{{ nats_user }}"
    group: "{{ nats_group }}"
    mode: 0755
    creates: "{{ nats_temp_unarchive }}/nats"
  when: not ansible_check_mode
  register: nats_archive_extracted

- name: Overwrite Nats binary if needed
  copy:
    src: "{{ nats_temp_unarchive }}/{{ nats_arch_folder_name }}/nats-server"
    dest: "{{ nats_bin_path }}/nats-server"
    remote_src: "True"
    mode: 0755
  register: nats_binary_updated
  when:
    - nats_archive_extracted is changed
    - not ansible_check_mode
  notify:
    - restart nats