From de2d2db3870a8a21fc9f4145d1d1455432772cae Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Tue, 28 Dec 2021 12:45:51 +0100 Subject: [PATCH] Split main into sub-tasks --- tasks/main.yml | 34 ++-------------------------- tasks/task_scripts.yml | 50 ++++++++++++++++++++++++++++++++++++++++++ tasks/task_utils.yml | 13 +++++++++++ 3 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 tasks/task_scripts.yml create mode 100644 tasks/task_utils.yml diff --git a/tasks/main.yml b/tasks/main.yml index 6db7528..558790a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,35 +1,5 @@ --- -- name: List installable sh scripts - become: false - local_action: shell ls -1 "{{role_path}}/files/bashrc.d/"*.sh - register: bash_scripts - failed_when: - bash_scripts.rc != 0 - changed_when: False -# tasks file for roles/glenux.bash -- name: Install main configuration files for bash - copy: > - src="{{item[1]}}" - dest="~/.{{item[1]|basename}}" - mode=0644 - become: true - become_user: "{{item[0]}}" - with_nested: - - "{{bash_users}}" - - ['bashrc', 'bash_profile', 'bash_aliases'] - -- name: Create bashrc.d directory - file: path=~/.bashrc.d state=directory - become: true - become_user: "{{item}}" - with_items: "{{bash_users}}" - -- name: Install bashrc.d files - copy: "src={{item[1]}} dest=~/.bashrc.d/{{item[1]|basename}}" - become: true - become_user: "{{item[0]}}" - with_nested: - - "{{bash_users}}" - - "{{bash_scripts.stdout_lines}}" +- include_tasks: task_utils.yml +- include_tasks: task_scripts.yml diff --git a/tasks/task_scripts.yml b/tasks/task_scripts.yml new file mode 100644 index 0000000..3dbc0be --- /dev/null +++ b/tasks/task_scripts.yml @@ -0,0 +1,50 @@ +--- +- name: List installable sh scripts + become: false + local_action: + module: ansible.builtin.shell + cmd: ls -1 "{{role_path}}/files/bashrc.d/"*.sh + register: bash_scripts + failed_when: bash_scripts.rc != 0 + # changed_when: False + +- name: Debug scripts + ansible.builtin.debug: + var: bash_scripts + +- name: Debug users + ansible.builtin.debug: + var: bash_users + +# tasks file for roles/glenux.bash +- name: Install main configuration files for bash + copy: + src: "{{item[1]}}" + dest: "~/.{{item[1]|basename}}" + mode: 0644 + become: true + become_user: "{{item[0]}}" + with_nested: + - "{{bash_users}}" + - ['bashrc', 'bash_profile', 'bash_aliases'] + +- meta: end_host + +- name: Create bashrc.d directory + file: + path: ~/.bashrc.d + state: directory + become: true + become_user: "{{item}}" + with_items: "{{bash_users}}" + +- name: Install bashrc.d files + copy: + src: "{{item[1]}}" + dest: "~/.bashrc.d/{{item[1]|basename}}" + become: true + become_user: "{{item[0]}}" + with_nested: + - "{{bash_users}}" + - "{{bash_scripts.stdout_lines}}" + diff --git a/tasks/task_utils.yml b/tasks/task_utils.yml new file mode 100644 index 0000000..39d6cbb --- /dev/null +++ b/tasks/task_utils.yml @@ -0,0 +1,13 @@ +--- + +- name: Install fasd + apt: + name: fasd + state: present + + +- name: Install fzf + apt: + name: fzf + state: present +