temp!
This commit is contained in:
parent
49b292126e
commit
071f30e104
71
roles/xremap/tasks/main.yaml
Normal file
71
roles/xremap/tasks/main.yaml
Normal file
@ -0,0 +1,71 @@
|
||||
---
|
||||
- name: stat executable
|
||||
stat:
|
||||
path: /usr/local/bin/xremap
|
||||
register: executable
|
||||
|
||||
- name: get installed version
|
||||
when: executable.stat.exists
|
||||
command: /usr/local/bin/xremap --version
|
||||
register: version_command
|
||||
changed_when: false
|
||||
|
||||
- name: extract version from command output
|
||||
when: executable.stat.exists
|
||||
set_fact:
|
||||
installed_version:
|
||||
'v{{version_command.stdout.strip() | regex_replace("^.*(\d+\.\d+\.\d+).*$", "\1")}}'
|
||||
|
||||
- name: get latest release
|
||||
uri:
|
||||
url: https://api.github.com/repos/k0kubun/xremap/releases/latest
|
||||
register: latest
|
||||
|
||||
- name: determine if install needed
|
||||
set_fact:
|
||||
needs_installed:
|
||||
'{{not executable.stat.exists or installed_version != latest.json.name}}'
|
||||
|
||||
- name: construct asset query
|
||||
set_fact:
|
||||
asset_query: >
|
||||
[?contains(name, `xremap-linux-{{ansible_architecture}}-{{
|
||||
ansible_env.XDG_CURRENT_DESKTOP | lower}}.zip`)] | [0]
|
||||
- name: get release asset
|
||||
set_fact:
|
||||
asset: '{{latest.json.assets | to_json | from_json | json_query(asset_query)}}'
|
||||
|
||||
- name: download release archive
|
||||
when: needs_installed
|
||||
become: true
|
||||
get_url:
|
||||
url: '{{asset.browser_download_url}}'
|
||||
dest: /usr/local/bin/xremap.zip
|
||||
|
||||
- name: extract release archive
|
||||
when: needs_installed
|
||||
become: true
|
||||
unarchive:
|
||||
src: /usr/local/bin/xremap.zip
|
||||
dest: /usr/local/bin
|
||||
|
||||
- name: remove release archive
|
||||
when: needs_installed
|
||||
become: true
|
||||
file:
|
||||
path: /usr/local/bin/xremap.zip
|
||||
state: absent
|
||||
|
||||
- name: add user to input group
|
||||
become: true
|
||||
user:
|
||||
name: '{{ansible_user_id}}'
|
||||
append: true
|
||||
groups: input
|
||||
|
||||
- name: add udev rule for input access
|
||||
become: true
|
||||
copy:
|
||||
content: |
|
||||
KERNEL=="uinput", GROUP="input", TAG+="uaccess"
|
||||
dest: /etc/udev/rules.d/input.rules
|
Loading…
x
Reference in New Issue
Block a user