home · contact · privacy
46a2b3e980aadf103945777b5ac8aa08dbb246c8
[config] / ansible / config_new.yml
1 ---
2 - hosts: all
3   user: root
4   become: yes
5   tasks:
6
7   - name: ensure directories for symlinks exist
8     file: state=directory dest={{item}}
9     with_lines: cat ~/config/ansible/files/dirs_new | sed -e 's/ *#.*$//'
10   - name: symlink system files
11     file: state=hard force=yes src={{item}} dest={{item|basename|regex_replace('___','/')}}
12     with_fileglob:
13     - ~/config/ansible/files/system_new/minimal/*
14     - ~/config/ansible/files/system_new/{{ system_name }}/*
15   - name: set hostname for current session
16     shell: hostname {{ system_name }} 
17
18   # Init package management.
19   - name: add palemoon repo signing key
20     apt_key:
21       url: https://download.opensuse.org/repositories/home:stevenpusser/Debian_9.0/Release.key
22       state: present
23   - name: update package lists
24     apt: update_cache=yes
25   - name: APT - dist-upgrade
26     apt: upgrade=dist
27
28   # Ensure power management.
29   - name: ensure power management tools are installed
30     apt: name={{item}} state=present
31     with_lines:
32     - cat ~/config/ansible/files/apt-mark_new/minimal/power_management | sed -e 's/ *#.*$//'
33     - cat ~/config/ansible/files/apt-mark_new/X200s/power_management | sed -e 's/ *#.*$//'
34   - name: start TLP
35     shell: tlp start
36
37   # Configure console.
38   #
39   # For some reason, some settings are only applied two reboots after this.
40   - name: symlink console config files
41     file: state=link force=yes src={{item}} dest={{item|basename|regex_replace('___','/')}}
42     with_fileglob: ~/config/ansible/files/console/*
43   - name: ensure locales and console-setup are installed
44     apt: name={{item}} state=present
45     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/console | sed -e 's/ *#.*$//'
46   - name: generate en_US.UTF-8 locale
47     locale_gen: name=en_US.UTF-8 state=present
48   - name: Touch keyboard config file so setupcon does not ignore it.
49     command: touch /etc/default/keyboard
50   - name: run setupcon to apply console settings from /etc/default/
51     command: setupcon
52
53   # Miscellaneous.
54   - name: Ensure dotfile symlinks
55     file: state=link force=yes src={{item}} dest=~/.{{item|basename}}
56     with_fileglob:
57     - ~/config/dotfiles/minimal/*
58     - ~/config/dotfiles/root/*
59   - name: ensure ~/.vimbackups directory
60     file: state=directory dest=~/.vimbackups
61   - name: ensure man-db, manpages are installed
62     apt: name={{item}} state=present
63     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/man | sed -e 's/ *#.*$//'
64   - name: set /etc/localtime
65     file: state=link force=yes src=/usr/share/zoneinfo/Europe/Berlin dest=/etc/localtime
66   - name: ensure various useful tools are installed – sudo, git, vim, less, openssh
67     apt: name={{item}} state=present
68     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/various_useful | sed -e 's/ *#.*$//'
69   - name: ensure boot messages are not cleared on start up
70     replace: dest=/etc/systemd/system/getty.target.wants/getty@tty1.service regexp='^TTYVTDisallocate=yes.*$' replace='TTYVTDisallocate=no'
71
72   # Config user.
73   - name: create user plom with sudo privileges and bash shell
74     user: name=plom groups=sudo shell=/bin/bash
75   #- name: have config repo in user directory
76   #  git: repo=https://github.com/plomlompom/config dest=/home/plom/config
77   #  become_user: plom
78   #  become_method: su
79
80   # Ensure X window environment.
81   - name: ensure minimal X window environment
82     apt: name={{item}} state=present
83     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/minimal_x | sed -e 's/ *#.*$//'
84   - name: ensure 3d acceleration
85     apt: name={{item}} state=present
86     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/3d_acceleration | sed -e 's/ *#.*$//'
87   #- name: ensure optimus switch
88   #  apt: name={{item}} state=present
89   #  with_lines: cat ~/config/ansible/files/apt-mark_new/W530/3d_acceleration | sed -e 's/ *#.*$//'
90   #- name: ensure user plom is in bumblebee group
91   #  user: name=plom groups=bumblebee append=yes
92   - name: ensure basic X tools
93     apt: name={{item}} state=present
94     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/basic_x_tools | sed -e 's/ *#.*$//'
95
96   ## Set up browser environment.
97   #- name: ensure qutebrowser
98   #  include: tasks/qutebrowser.yml
99   - name: ensure browser environment
100     apt: name={{item}} state=present
101     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/browser_environment | sed -e 's/ *#.*$//'
102
103   # Ensure wifi.
104   - name: ensure wifi configuration
105     apt: name={{item}} state=present
106     with_lines:
107     - cat ~/config/ansible/files/apt-mark_new/minimal/wifi | sed -e 's/ *#.*$//'
108     - cat ~/config/ansible/files/apt-mark_new/X200s/wifi | sed -e 's/ *#.*$//'
109   #- name: ensure wicd
110   #  apt: name={{item}} state=present
111   #  with_lines: cat ~/config/ansible/files/apt-mark_new/W530/wicd | sed -e 's/ *#.*$//'
112
113   # Ensure audio/video consumption necessities.
114   - name: ensure multimedia tools
115     apt: name={{item}} state=present
116     with_lines: cat ~/config/ansible/files/apt-mark_new/minimal/multimedia | sed -e 's/ *#.*$//'
117   #- name: ensure multimedia tools
118   #  apt: name={{item}} state=present
119   #  with_lines: cat ~/config/ansible/files/apt-mark_new/W530/multimedia | sed -e 's/ *#.*$//'
120
121   # Ensure hotkeys.
122   #
123   # For some reason, the brightness hotkeys still won't be available unless acpid is restarted (yes, after reboot).
124   #- name: ensure hotkeys 
125   #  apt: name={{item}} state=present
126   #  with_lines: cat ~/config/ansible/files/apt-mark/hotkeys | sed -e 's/ *#.*$//'
127
128   # Remove undesired packages
129   - name: collect desired packages
130     shell: cat files/apt-mark_new/minimal/* files/apt-mark_new/{{ system_name }}/*  | sed -e 's/ *#.*$//' > /tmp/white_list_unsorted && sort /tmp/white_list_unsorted > /tmp/white_list_sorted
131   - name: collect currently installed packages
132     shell: dpkg-query -Wf '${Package}\n' > /tmp/all_unsorted && sort /tmp/all_unsorted > /tmp/all_sorted
133   - name: create black list of packages to mark as automatically installed from the difference between the required packages and the packages currently installed
134     shell: comm -3 /tmp/all_sorted /tmp/white_list_sorted > /tmp/list_black
135   - name: mark all packages from black list as automatically installed
136     shell: apt-mark auto $(cat /tmp/list_black)
137   - name: mark all packages from white list as manually installed
138     shell: apt-mark manual $(cat /tmp/white_list_unsorted)
139   - name: purge all packages automatically installed that are not depended on
140     shell: DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove
141