Trying to get some roles set up for minecraft server updates
This commit is contained in:
49
clacm/minecraft/roles/update_plugin/tasks/main.yml
Normal file
49
clacm/minecraft/roles/update_plugin/tasks/main.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
- name: Set file path var
|
||||
ansible.builtin.set_fact:
|
||||
plugin_file_path: "{{ query('ansible.builtin.fileglob', update_plugin_server_base_dir + '/plugins/' + update_plugin_plugin_filename_glob) | first }}"
|
||||
|
||||
- name: Stat plugin file
|
||||
ansible.builtin.stat:
|
||||
path: "{{ plugin_file_path }}"
|
||||
register: plugin_file_stat
|
||||
|
||||
- name: Fail if plugin not installed
|
||||
ansible.builtin.fail:
|
||||
msg: "The plugin specified by glob {{ update_plugin_plugin_filename_glob }} doesn't exist"
|
||||
when: update_plugin_fail_if_plugin_not_installed and not plugin_fail_stat.stat.exists
|
||||
|
||||
- name: Download latest plugin version
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ update_plugin_latest_plugin_dl_url }}"
|
||||
dest: "/tmp/{{ update_plugin_plugin_final_filename }}"
|
||||
mode: "{{ update_plugin_plugin_mode }}"
|
||||
owner: "{{ update_plugin_plugin_owner }}"
|
||||
group: "{{ update_plugin_plugin_group }}"
|
||||
|
||||
- name: Stat new file
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/{{ update_plugin_plugin_final_filename }}"
|
||||
register: new_plugin_file_stat
|
||||
|
||||
- name: Do update process block
|
||||
when: plugin_file_stat.stat.checksum != new_plugin_file_stat.stat.checksum
|
||||
block:
|
||||
- name: Remove old file if it exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ plugin_file_path }}"
|
||||
state: absent
|
||||
|
||||
- name: Copy the new file to the plugins path
|
||||
ansible.builtin.copy:
|
||||
src: "/tmp/{{ update_plugin_plugin_final_filename }}"
|
||||
dest: "{{ update_plugin_server_base_dir }}/plugins"
|
||||
mode: "{{ update_plugin_plugin_mode }}"
|
||||
owner: "{{ update_plugin_plugin_owner }}"
|
||||
group: "{{ update_plugin_plugin_group }}"
|
||||
remote_src: true
|
||||
|
||||
- name: Remove new plugin file
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/{{ update_plugin_plugin_final_filename }}"
|
||||
state: absent
|
||||
Reference in New Issue
Block a user