mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-07-27 08:15:54 +02:00
Update to 2023-07-03 15:00
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Compress previous version
|
||||
command: tar cf {{ consul_root_dir }}/archives/{{ consul_current_version }}.tar.zst --use-compress-program=zstd ./
|
||||
args:
|
||||
chdir: "{{ consul_root_dir }}/archives/{{ consul_current_version }}"
|
||||
environment:
|
||||
ZSTD_CLEVEL: 10
|
||||
tags: consul
|
||||
|
||||
- name: Remove archive dir
|
||||
file: path={{ consul_root_dir }}/archives/{{ consul_current_version }} state=absent
|
||||
tags: consul
|
||||
|
@@ -1,27 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Create the archive dir
|
||||
file: path={{ consul_root_dir }}/archives/{{ consul_current_version }} state=directory
|
||||
tags: consul
|
||||
|
||||
- name: Snapshot consul data
|
||||
command: "{{ consul_root_dir }}/bin/consul snapshot save {{ consul_root_dir }}/archives/{{ consul_current_version }}/consul.snap"
|
||||
args:
|
||||
creates: "{{ consul_root_dir }}/archives/{{ consul_current_version }}/consul.snap"
|
||||
when:
|
||||
- consul_conf.server
|
||||
- not consul_conf.acl.enabled or consul_mgm_token is defined
|
||||
environment:
|
||||
CONSUL_TOKEN: "{{ consul_mgm_token | default('') }}"
|
||||
tags: consul
|
||||
|
||||
- name: Backup previous version
|
||||
synchronize:
|
||||
src: "{{ consul_root_dir }}/{{ item }}"
|
||||
dest: "{{ consul_root_dir }}/archives/{{ consul_current_version }}/"
|
||||
compress: False
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
loop:
|
||||
- bin
|
||||
tags: consul
|
||||
|
@@ -3,6 +3,6 @@
|
||||
- name: Remove tmp and obsolete files
|
||||
file: path={{ item }} state=absent
|
||||
loop:
|
||||
- "{{ consul_root_dir }}/tmp/consul_{{ consul_version }}_linux_amd64.zip"
|
||||
- "{{ consul_root_dir }}/tmp/consul"
|
||||
- "{{ consul_root_dir }}/archives"
|
||||
- "{{ consul_root_dir }}/bin"
|
||||
tags: consul
|
||||
|
@@ -7,10 +7,6 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: 755
|
||||
- dir: archives
|
||||
owner: root
|
||||
group: root
|
||||
mode: 700
|
||||
- dir: backup
|
||||
owner: root
|
||||
group: root
|
||||
@@ -19,7 +15,6 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: 700
|
||||
- dir: bin
|
||||
- dir: tmp
|
||||
owner: "{{ consul_user }}"
|
||||
group: "{{ consul_user }}"
|
||||
|
@@ -1,19 +1,6 @@
|
||||
---
|
||||
|
||||
- set_fact: consul_install_mode='none'
|
||||
tags: consul
|
||||
|
||||
- name: Detect if consul is installed
|
||||
stat: path=/usr/local/bin/consul
|
||||
register: consul_bin
|
||||
tags: consul
|
||||
|
||||
- when: not consul_bin.stat.exists
|
||||
set_fact: consul_install_mode='install'
|
||||
tags: consul
|
||||
|
||||
- when: consul_bin.stat.exists
|
||||
block:
|
||||
- block:
|
||||
- name: Detect installed version
|
||||
shell: /usr/local/bin/consul version | head -1 | perl -pe 's/Consul v(\d+(\.\d+)*)/$1/'
|
||||
changed_when: False
|
||||
@@ -21,7 +8,3 @@
|
||||
- set_fact: consul_current_version={{ consul_current_version.stdout }}
|
||||
tags: consul
|
||||
|
||||
- when: consul_bin.stat.exists and consul_current_version != consul_version
|
||||
set_fact: consul_install_mode='upgrade'
|
||||
tags: consul
|
||||
|
||||
|
@@ -1,49 +1,5 @@
|
||||
---
|
||||
|
||||
- name: Install needed tools
|
||||
package:
|
||||
name:
|
||||
- tar
|
||||
- zstd
|
||||
- unzip
|
||||
- acl
|
||||
tags: consul
|
||||
|
||||
- when: consul_install_mode != 'none'
|
||||
block:
|
||||
- name: Download consul
|
||||
get_url:
|
||||
url: "{{ consul_archive_url }}"
|
||||
dest: "{{ consul_root_dir }}/tmp"
|
||||
checksum: sha256:{{ consul_archive_sha256 }}
|
||||
|
||||
- name: Extract the archive
|
||||
unarchive:
|
||||
src: "{{ consul_root_dir }}/tmp/consul_{{ consul_version }}_linux_amd64.zip"
|
||||
dest: "{{ consul_root_dir }}/tmp"
|
||||
remote_src: True
|
||||
|
||||
- name: Install consul binary
|
||||
copy:
|
||||
src: "{{ consul_root_dir }}/tmp/consul"
|
||||
dest: "{{ consul_root_dir }}/bin/consul"
|
||||
remote_src: True
|
||||
mode: 755
|
||||
notify: restart consul
|
||||
|
||||
- name: Link in /usr/local/bin
|
||||
file: src={{ consul_root_dir }}/bin/consul dest=/usr/local/bin/consul state=link force=True
|
||||
|
||||
tags: consul
|
||||
|
||||
- name: Install bash completion support
|
||||
copy:
|
||||
content: |
|
||||
complete -C {{ consul_root_dir }}/bin/consul consul
|
||||
dest: /etc/bash_completion.d/consul
|
||||
mode: 0644
|
||||
tags: consul
|
||||
|
||||
- name: Deploy systemd service unit
|
||||
template: src=consul.service.j2 dest=/etc/systemd/system/consul.service
|
||||
register: consul_unit
|
||||
@@ -67,3 +23,17 @@
|
||||
- pre
|
||||
- post
|
||||
tags: consul
|
||||
|
||||
- name: Create tmpfiles fragment
|
||||
copy:
|
||||
content: |
|
||||
d /run/nomad 770 root {{ consul_user }}
|
||||
dest: /etc/tmpfiles.d/consul.conf
|
||||
notify: systemd-tmpfiles
|
||||
register: consul_tmpfiles
|
||||
tags: consul
|
||||
|
||||
- name: Create tmpfiles
|
||||
command: systemd-tmpfiles --create
|
||||
when: consul_tmpfiles.changed
|
||||
tags: consul
|
||||
|
@@ -9,10 +9,6 @@
|
||||
- include_tasks: facts.yml
|
||||
tags: always
|
||||
|
||||
- include_tasks: archive_pre.yml
|
||||
when: consul_install_mode | default('none') == 'upgrade'
|
||||
tags: always
|
||||
|
||||
- include_tasks: install.yml
|
||||
tags: always
|
||||
|
||||
@@ -26,10 +22,6 @@
|
||||
- include_tasks: services.yml
|
||||
tags: always
|
||||
|
||||
- include_tasks: archive_post.yml
|
||||
when: consul_install_mode | default('none') == 'upgrade'
|
||||
tags: always
|
||||
|
||||
- include_tasks: cleanup.yml
|
||||
tags: always
|
||||
|
||||
|
Reference in New Issue
Block a user