aboutsummaryrefslogtreecommitdiffstats
path: root/roles/common/tasks/main.yml
blob: acbcb1c3c49aefef304da696a631d09e0dee7eb8 (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
59
60
61
62
63

# common ~~ tasks/main.yml

---

- name: Setup repositories for Alpine
  shell: |
    echo "https://mirror.ungleich.ch/mirror/packages/alpine/edge/main/" > /etc/apk/repositories
    echo "https://mirror.ungleich.ch/mirror/packages/alpine/edge/community/" >> /etc/apk/repositories
    echo "https://mirror.ungleich.ch/mirror/packages/alpine/edge/releases/" >> /etc/apk/repositories
  when: "'alpine' in group_names"

- name: Check installation of package "{{ item }}"
  package:
    name: "{{ item }}"
    state: present

  loop:
    - "{{ packages.zsh }}"
    - "{{ packages.curl }}"
    - "{{ packages.tmux }}"
    - "{{ packages.wget }}"
    - "{{ packages.figlet }}"
    - "{{ packages.neovim }}"
    - "{{ packages.pip }}"
    - util-linux
    - shadow

  ignore_errors: yes


- name: Copy zshrc configuration file
  copy:
    src: zshrc
    dest: "{{ path_zshrc }}"
    owner: root
    group: "{{ group.root }}"
    mode: 0644

- name: Copy tmux configuration file
  copy:
    src: tmux.conf
    dest: /etc/tmux.conf
    owner: root
    group: "{{ group.root }}"
    mode: 0644

- name: Synchronize host hostname with config hostname
  hostname:
    name: "{{ inventory_hostname }}"

- name: Retrieve all valid users for zsh
  shell: awk -F ":" '{ if($3 == 0 || $3 > 999 && $3 < 16000) { print $1 }}' /etc/passwd
  register: valid_users_shell

- debug:
    var: valid_users_shell.stdout

- name: Change shell for all valid users to zsh
  user:
    name: "{{ item }}"
    shell: "{{ path_zsh }}" 
  loop: "{{ valid_users_shell.stdout_lines }}"
remember that computers suck.