From: Ralf Jung Date: Thu, 10 May 2018 10:58:34 +0000 (+0200) Subject: make base a role X-Git-Url: https://git.ralfj.de/ansible.git/commitdiff_plain/7fe5eee7ca65689e40bef73522cc87ef2ce19c9c?ds=sidebyside;hp=bea8c24ee7a473aef46ce452a8f1578487ac983e make base a role --- diff --git a/base.yml b/base.yml index 4b94ecd..f5835a9 100644 --- a/base.yml +++ b/base.yml @@ -1,48 +1,4 @@ # basic system preparation - hosts: all - tasks: - # packages - - name: check minimal system version - when: not (ansible_distribution == "Debian" and ansible_lsb.major_release|int >= 9) - command: "false" - - name: detect if we have backports in the sources.list - command: fgrep backports /etc/apt/sources.list - register: backports - failed_when: backports.rc == 2 - changed_when: False - - name: add backports repository - when: backports.rc != 0 - apt_repository: repo='deb http://httpredir.debian.org/debian {{ansible_distribution_release}}-backports main contrib non-free' state=present update_cache=yes - - name: get rid of packages we do not want - apt: name=exim4-base,rpcbind state=absent autoremove=yes - - name: install needrestart (from backports) - apt: name=needrestart state=latest default_release={{ansible_distribution_release}}-backports - - name: install some basic tools - apt: name=aptitude,rsync,git,mercurial,curl,apt-transport-https,psmisc,dnsutils,tree,htop state=latest - # server-scripts - - name: clone server-scripts git repository - git: - dest: /root/server-scripts - repo: 'https://git.ralfj.de/server-scripts.git' - version: 07d301fd8adeaf8ad40591a418da394ad37816ce - # configuration - - name: configure root shell - copy: - dest: /root/{{ item }} - remote_src: True - src: /etc/skel/{{ item }} - loop: - - .profile - - .bashrc - - .bash_logout - - name: configure systemd-timesyncd - copy: - dest: /etc/systemd/timesyncd.conf - content: | - # See timesyncd.conf(5) for details. - [Time] - NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org - register: timesyncd_conf - - name: restart systemd-timesyncd - when: timesyncd_conf.changed - service: name=systemd-timesyncd state=restarted enabled=yes + roles: + - base diff --git a/roles/base/files/timesyncd.conf b/roles/base/files/timesyncd.conf new file mode 100644 index 0000000..15deae9 --- /dev/null +++ b/roles/base/files/timesyncd.conf @@ -0,0 +1,3 @@ +# See timesyncd.conf(5) for details. +[Time] +NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org diff --git a/roles/base/handlers/main.yml b/roles/base/handlers/main.yml new file mode 100644 index 0000000..abeac1f --- /dev/null +++ b/roles/base/handlers/main.yml @@ -0,0 +1,2 @@ +- name: timesyncd + service: name=timesyncd state=restarted diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml new file mode 100644 index 0000000..5f264c6 --- /dev/null +++ b/roles/base/tasks/main.yml @@ -0,0 +1,39 @@ +# packages +- name: check minimal system version + when: not (ansible_distribution == "Debian" and ansible_lsb.major_release|int >= 9) + command: "false" +- name: detect if we have backports in the sources.list + command: fgrep backports /etc/apt/sources.list + register: backports + failed_when: backports.rc == 2 + changed_when: False +- name: add backports repository + when: backports.rc != 0 + apt_repository: repo='deb http://httpredir.debian.org/debian {{ansible_distribution_release}}-backports main contrib non-free' state=present update_cache=yes +- name: get rid of packages we do not want + apt: name=exim4-base,rpcbind state=absent autoremove=yes +- name: install needrestart (from backports) + apt: name=needrestart state=latest default_release={{ansible_distribution_release}}-backports +- name: install some basic tools + apt: name=aptitude,rsync,git,mercurial,curl,apt-transport-https,psmisc,dnsutils,tree,htop state=latest +# server-scripts +- name: clone server-scripts git repository + git: + dest: /root/server-scripts + repo: 'https://git.ralfj.de/server-scripts.git' + version: 07d301fd8adeaf8ad40591a418da394ad37816ce +# configuration +- name: configure root shell + copy: + dest: /root/{{ item }} + remote_src: True + src: /etc/skel/{{ item }} + loop: + - .profile + - .bashrc + - .bash_logout +- name: configure systemd-timesyncd + copy: + dest: /etc/systemd/timesyncd.conf + src: files/timesyncd.conf + notify: timesyncd