summaryrefslogblamecommitdiff
path: root/roles/init/tasks/main.yml
blob: e60bb2a843f8520e1b56705c879828c95edbfb52 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
   









                            
                       

                                                                                                                
                     
                                 
                




                                          


                                                                                                  
                                          







                                                                                                                                                 
                                          




                                                                                                                                                     



                                                                                                                          
---
- name: Create XDG dirs
  file:
    path: "{{ item }}"
    state: directory
  loop:
    - "$XDG_CONFIG_HOME"
    - "$XDG_STATE_HOME"
    - "$XDG_STATE_HOME/bash"
    - "$XDG_DATA_HOME"
    - "$XDG_CACHE_HOME"
    - "$HOME/Downloads"
- name: Get gnupg runtime folder name
  shell: 'GNUPGHOME=$XDG_CONFIG_HOME/gnupg gpgconf --list-dirs socketdir | sed -e "s@$XDG_RUNTIME_DIR/gnupg/@@"'
  changed_when: false
  register: gnupg_runtime_dir_cmd
  check_mode: no
- name: Add pam_environment
  register: pam_environment
  template:
    src: pam_environment.j2
    dest: $XDG_CONFIG_HOME/pam_environment
- name: Remove old lines in bashrc_temp
  lineinfile:
    line: "{{ ('unset ' ~ item | regex_replace('=.*')) if item != '' and item.0 != '#' else '' }}"
    dest: $XDG_STATE_HOME/bash/bashrc_temp
    insertafter: EOF
    create: true
    state: present
  loop: "{{ pam_environment.diff.0.before.split('\n')|difference(pam_environment.diff.0.after.split('\n')) | regex_replace('[\\\\t]*DEFAULT') }}"
  when: pam_environment.changed
- name: Add new lines in bashrc_temp
  lineinfile:
    line: "{{ ('export ' ~ item) if item != '' and item.0 != '#' else '' }}"
    dest: $XDG_STATE_HOME/bash/bashrc_temp
    insertafter: EOF
    create: true
    state: present
  loop: "{{ pam_environment.diff.0.after.split('\n')|difference(pam_environment.diff.0.before.split('\n')) | regex_replace('[\\\\t]*DEFAULT', '') }}"
  when: pam_environment.changed
- name: Signal the change
  when: pam_environment.changed
  debug:
    msg: "\u26A0\uFE0F \u26A0\uFE0F  You need to log out and back in to update your environment \u26A0\uFE0F \u26A0\uFE0F"