fix: suppoer relative and absolute paths
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Markus Pesch 2024-03-02 22:32:44 +01:00
parent 5907f1617a
commit 804eb02075
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 12 additions and 7 deletions

View File

@ -26,7 +26,7 @@ unix_users: {}
# btrfs: false # btrfs: false
# shell: /bin/bash # shell: /bin/bash
# shell_rc_files: # shell_rc_files:
# - file: "/home/alice/.bashrc.d" # - file: "/home/alice/.bashrc.d/docker.bashrc" # absolute or relative path to home dir
# aliases: # aliases:
# - key: "dcd" # - key: "dcd"
# value: "docker-compose down" # value: "docker-compose down"

View File

@ -1,25 +1,30 @@
--- ---
- name: "Create shell rc file directory {{ shell_rc_file.file | dirname }}" - name: "Determine shell rc directory"
ansible.builtin.set_fact:
# path_join examples: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/path_join_filter.html#examples
_shell_rc_file: "{{ (user_user_home, '.bashrc.d', shell_rc_file.file) | path_join }}"
- name: "Create shell rc directory: {{ _shell_rc_file | dirname }}"
ansible.builtin.file: ansible.builtin.file:
path: "{{ shell_rc_file.file | dirname }}" path: "{{ _shell_rc_file | dirname }}"
owner: "{{ unix_user.key }}" owner: "{{ unix_user.key }}"
group: "{{ unix_user.value.group | default('users') }}" group: "{{ unix_user.value.group | default('users') }}"
mode: "0755" mode: "0755"
state: "directory" state: "directory"
- name: "Create shell rc file {{ shell_rc_file.file }}" - name: "Create shell rc file: {{ _shell_rc_file }}"
ansible.builtin.template: ansible.builtin.template:
src: shell_rc_file.j2 src: shell_rc_file.j2
dest: "{{ shell_rc_file.file }}" dest: "{{ _shell_rc_file }}"
owner: "{{ unix_user.key }}" owner: "{{ unix_user.key }}"
group: "{{ unix_user.value.group | default('users') }}" group: "{{ unix_user.value.group | default('users') }}"
mode: "0644" mode: "0644"
- name: "Source shell rc file {{ shell_rc_file.file }}" - name: "Source shell rc file: {{ _shell_rc_file }}"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "{{ user_user_home }}/.bashrc" path: "{{ user_user_home }}/.bashrc"
line: "source \"{{ shell_rc_file.file }}\"" line: "source \"{{ _shell_rc_file }}\""
owner: "{{ unix_user.key }}" owner: "{{ unix_user.key }}"
group: "{{ unix_user.value.group | default('users') }}" group: "{{ unix_user.value.group | default('users') }}"
state: "present" state: "present"