summaryrefslogtreecommitdiff
path: root/roles/core/zsh/tasks/main.yml
blob: a5ae60ec4fb1dc5fb61f8043390ce93ca21cfa1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
- name: load os/distrubtion/version specific variables
  include_vars: "{{ item }}"
  with_first_found:
    - files:
        - "{{ ansible_distribution_release }}.yml"
        - "{{ ansible_distribution }}.yml"
        - "{{ ansible_os_family }}.yml"

- name: install zsh package
  package:
    name: zsh
    state: present

- name: install zsh-config
  loop:
  - src: "zshrc"
    dest: "{{ zsh_conf_base_dir }}/zshrc"
  - src: "zshrc.skel"
    dest: "/etc/skel/.zshrc"
  loop_control:
    label: "{{ item.dest }}"
  copy:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"

- name: set zsh as default shell
  loop: "{{ [ 'root' ] | union(zsh_loginshell_user | default([])) }}"
  user:
    name: "{{ item }}"
    shell: "{{ zsh_bin_path }}"

- name: make zsh the default shell for new users
  loop: "{{ zsh_default_shell_lineinfile | dict2items }}"
  loop_control:
    label: "{{ item.key }} ('{{ item.value.regexp }}' -> '{{ item.value.line }}')"
  lineinfile:
    path: "{{ item.key }}"
    regexp: "{{ item.value.regexp }}"
    line: "{{ item.value.line }}"
    create: yes

- name: install shell banner
  when: zsh_banner is defined
  block:

    - name: install banner script
      template:
        src: "banner.{{ zsh_banner }}.j2"
        dest: /etc/banner.sh
        mode: 0755

    - name: enable banner for zsh login
      lineinfile:
        path: "{{ zsh_conf_base_dir }}/zlogin"
        line: /etc/banner.sh
        insertbefore: "^## END OF FILE #"
        create: yes