home · contact · privacy
c49e7c9551e75ead1f7bb8eefa3d04b5e69916e5
[config] / ansible / config.yml
1 ---
2 - hosts: all
3   user: root
4   become: yes
5   tasks:
6
7   - name: symlink system files
8     file: state=hard force=yes src={{item}} dest={{item|basename|regex_replace('___','/')}}
9     with_fileglob: ~/config/ansible/files/system/*
10   - name: set hostname for current session
11     shell: hostname w530
12
13   # Configure package management.
14   - name: update package lists
15     apt: update_cache=yes
16   - name: APT - dist-upgrade
17     apt: upgrade=dist
18
19   # Ensure power management.
20   - name: ensure power management tools are installed
21     apt: name={{item}} state=present
22     with_lines: cat ~/config/ansible/files/apt-mark/power_management | sed -e 's/ *#.*$//'
23     #with_items:
24     #- tlp
25     #- acpi-call-dkms
26   - name: start TLP
27     shell: tlp start
28
29   # Configure console.
30   - name: symlink console config files
31     file: state=link force=yes src={{item}} dest={{item|basename|regex_replace('___','/')}}
32     with_fileglob: ~/config/ansible/files/console/*
33   - name: ensure locales and console-setup are installed
34     apt: name={{item}} state=present
35     with_lines: cat ~/config/ansible/files/apt-mark/console | sed -e 's/ *#.*$//'
36     #with_items:
37     #- locales
38     #- console-setup
39   - name: generate en_US.UTF-8 locale
40     locale_gen: name=en_US.UTF-8 state=present
41   - name: run setupcon to apply console settings from /etc/default/
42     command: setupcon
43
44   # Miscellaneous.
45   - name: Ensure dotfile symlinks
46     file: state=link force=yes src={{item}} dest=~/.{{item|basename}}
47     with_fileglob:
48     - ~/config/dotfiles/minimal/*
49     - ~/config/dotfiles/root/*
50   - name: ensure ~/.vimbackups directory
51     file: state=directory dest=~/.vimbackups
52   - name: ensure man-db, manpages is installed
53     apt: name={{item}} state=present
54     with_lines: cat ~/config/ansible/files/apt-mark/man | sed -e 's/ *#.*$//'
55   - name: set /etc/localtime
56     file: state=link force=yes src=/usr/share/zoneinfo/Europe/Berlin dest=/etc/localtime
57   - name: ensure sudo, git, vim, less, openssh are installed
58     apt: name={{item}} state=present
59     with_lines: cat ~/config/ansible/files/apt-mark/sudo_git_vim_less_openssh | sed -e 's/ *#.*$//'
60   - name: ensure boot messages are not cleared on start up
61     replace: dest=/etc/systemd/system/getty.target.wants/getty@tty1.service regexp='^TTYVTDisallocate=yes.*$' replace='TTYVTDisallocate=no'
62
63   # Config user.
64   - name: create user plom with sudo privileges and bash shell
65     user: name=plom groups=sudo shell=/bin/bash
66   - name: have config repo in user directory
67     git: repo=https://github.com/plomlompom/config dest=/home/plom/config
68     become_user: plom
69     become_method: su
70
71   # Ensure X window environment.
72   - name: ensure minimal X window environment
73     apt: name={{item}} state=present
74     with_lines: cat ~/config/ansible/files/apt-mark/minimal_x | sed -e 's/ *#.*$//'
75   - name: ensure 3d acceleration and optimus switch
76     apt: name={{item}} state=present
77     with_lines: cat ~/config/ansible/files/apt-mark/3d_acceleration | sed -e 's/ *#.*$//'
78   - name: ensure basic X tools
79     apt: name={{item}} state=present
80     with_lines: cat ~/config/ansible/files/apt-mark/basic_x_tools | sed -e 's/ *#.*$//'
81
82   # Set up pentadactyl.
83   - name: ensure browser environment
84     apt: name={{item}} state=present
85     with_lines: cat ~/config/ansible/files/apt-mark/browser_environment | sed -e 's/ *#.*$//'
86
87   # Remove undesired packages
88   - name: collect desired packages
89     shell: cat files/apt-mark/*  | sed -e 's/ *#.*$//' > /tmp/white_list_unsorted && sort /tmp/white_list_unsorted > /tmp/white_list_sorted
90   - name: collect currently installed packages
91     shell: dpkg-query -Wf '${Package}\n' > /tmp/all_unsorted && sort /tmp/all_unsorted > /tmp/all_sorted
92   - name: create black list of packages to mark as automatically installed from the difference between the required packages and the packages currently installed
93     shell: comm -3 /tmp/all_sorted /tmp/white_list_sorted > /tmp/list_black
94   - name: mark all packages from black list as automatically installed
95     shell: apt-mark auto $(cat /tmp/list_black)
96   - name: mark all packages from white list as manually installed
97     shell: apt-mark manual $(cat /tmp/white_list_unsorted)
98   - name: purge all packages automatically installed that are not depended on
99     shell: DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove