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