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