Refactor to reduce config in group_vars
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
---
|
||||
- name: Glob all files in role directory
|
||||
ansible.builtin.find:
|
||||
paths: "{{ role_path }}"
|
||||
depth: 1
|
||||
file_type: file
|
||||
register: scripts_files
|
||||
|
||||
- name: Deploy scripts to user's local bin
|
||||
ansible.builtin.include_tasks: ../../deploy_files.yml
|
||||
vars:
|
||||
var_prefix: scripts
|
||||
subdir: ''
|
||||
target_root: "{{ ansible_facts.env.HOME }}/.local/bin"
|
||||
use_symlinks: true
|
||||
become_root: false
|
||||
- name: "Ensure script directory exist"
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_facts.env.HOME }}/.local/bin"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: "Deploy scripts (local with symlinks)"
|
||||
ansible.builtin.file:
|
||||
src: "{{ item.path }}"
|
||||
dest: "{{ ansible_facts.env.HOME }}/.local/bin/{{ item.path | basename }}"
|
||||
state: link
|
||||
force: true
|
||||
loop: "{{ scripts_files.files }}"
|
||||
when: ansible_connection in ['local', 'localhost']
|
||||
|
||||
- name: "Deploy scripts (remote with copy)"
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.path }}"
|
||||
dest: "{{ ansible_facts.env.HOME }}/.local/bin/{{ item.path | basename }}"
|
||||
mode: '0755'
|
||||
loop: "{{ scripts_files.files }}"
|
||||
when: ansible_connection not in ['local', 'localhost']
|
||||
|
||||
Reference in New Issue
Block a user