4b94ecd03221aa83dc10bc212fc38f93e8bb357b
[ansible.git] / base.yml
1 # basic system preparation
2 - hosts: all
3   tasks:
4   # packages
5   - name: check minimal system version
6     when: not (ansible_distribution == "Debian" and ansible_lsb.major_release|int >= 9)
7     command: "false"
8   - name: detect if we have backports in the sources.list
9     command: fgrep backports /etc/apt/sources.list
10     register: backports
11     failed_when: backports.rc == 2
12     changed_when: False
13   - name: add backports repository
14     when: backports.rc != 0
15     apt_repository: repo='deb http://httpredir.debian.org/debian {{ansible_distribution_release}}-backports main contrib non-free' state=present update_cache=yes
16   - name: get rid of packages we do not want
17     apt: name=exim4-base,rpcbind state=absent autoremove=yes
18   - name: install needrestart (from backports)
19     apt: name=needrestart state=latest default_release={{ansible_distribution_release}}-backports
20   - name: install some basic tools
21     apt: name=aptitude,rsync,git,mercurial,curl,apt-transport-https,psmisc,dnsutils,tree,htop state=latest
22   # server-scripts
23   - name: clone server-scripts git repository
24     git:
25       dest: /root/server-scripts
26       repo: 'https://git.ralfj.de/server-scripts.git'
27       version: 07d301fd8adeaf8ad40591a418da394ad37816ce
28   # configuration
29   - name: configure root shell
30     copy:
31       dest: /root/{{ item }}
32       remote_src: True
33       src: /etc/skel/{{ item }}
34     loop:
35     - .profile
36     - .bashrc
37     - .bash_logout
38   - name: configure systemd-timesyncd
39     copy:
40       dest: /etc/systemd/timesyncd.conf
41       content: |
42                # See timesyncd.conf(5) for details.
43                [Time]
44                NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
45     register: timesyncd_conf
46   - name: restart systemd-timesyncd
47     when: timesyncd_conf.changed
48     service: name=systemd-timesyncd state=restarted enabled=yes