You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

108 lines
3.2 KiB

---
# Role commun a toutes les machines
# vars: admin_ssh_keys, repositories, default_packages, ntp_server1, ntp_server2, description
# Bootstrap if necessary (install python-apt)
- name: Bootstrap if necessary
tags: bootstrap
raw: python -c "import apt" || DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y install python-apt
when: ansible_distribution == 'Debian'
# Check mandatory variables
- name: Check vars
fail: msg="Missing variable admin_ssh_keys"
when: admin_ssh_keys is not defined
- name: Check vars
fail: msg="Missing variable default_packages_debian"
when: default_packages_debian is not defined
- name: Check vars
fail: msg="Missing variable description"
when: description is not defined
- name: Check vars
fail: msg="Missing variable ntp_servers"
when: ntp_servers is not defined
- name: Check vars
fail: msg="Missing variable disable_ipv6"
when: disable_ipv6 is not defined
# SSH
- name: Deploy SSH keys
tags: ssh_keys
authorized_key: user=root key="{{item}}"
with_items: admin_ssh_keys
# Packages
- name: Install default packages Debian.
apt: pkg={{item}} state=installed
with_items: default_packages_debian
when: ansible_distribution == 'Debian'
# Configure NTP
- name: Configure NTP
tags: ntp
template: src=etc-ntp.conf.j2 dest=/etc/ntp.conf
# Basic Shell & vim configuration
- name: Create .vim/colors
tags: custom
file: path=/root/.vim/colors state=directory
- name: Custom .bashrc, .vimrc, .inputrc and Wombat vim colors theme
tags: custom
copy: src={{ item.src }} dest={{ item.dest }}
with_items:
- { src: 'root-.bashrc', dest: '/root/.bashrc' }
- { src: 'root-.vimrc', dest: '/root/.vimrc' }
- { src: 'root-.inputrc', dest: '/root/.inputrc' }
- { src: 'root-.vim-colors-wombat.vim', dest: '/root/.vim/colors/wombat.vim' }
# Set motd and README.root
- name: Set the motd
tags: custom
template: src=etc-motd.j2 dest=/etc/motd
- name: Modify /root/.profile, Add basic README.root
tags: custom
copy: src={{ item.src }} dest={{ item.dest }}
with_items:
- { src: 'root-.profile', dest: '/root/.profile' }
- { src: 'root-README.root', dest: '/root/README.root' }
when: initialize == 'True'
# Env setup
- name: Set the locale
tags: environ
debconf: name=locales question='default_environment_locale' value='fr_FR.UTF-8' vtype='multiselect'
debconf: name=locales question='locales_to_be_generated' value='en_US.UTF-8 UTF-8, fr_FR.UTF-8 UTF-8' vtype='multiselect'
debconf: name=locales question='locales/locales_to_be_generated' value='fr_FR.UTF-8, UTF-8' vtype='multiselect'
when: ansible_distribution == 'Debian'
- name: Set timezone
copy: content='{{ tzdata_timezone | default('Europe/Paris') }}'
dest=/etc/timezone owner=root group=root mode=0644
notify:
- update timezone
when: ansible_distribution == 'Debian'
- name: Disable IPv6 (need reboot)
tags: environ
lineinfile: dest=/etc/modprobe.d/blacklist line="blacklist ipv6" state="present" create="yes"
when: disable_ipv6 == 'True'
- name: Enable IPv6 (need reboot)
tags: environ
lineinfile: dest=/etc/modprobe.d/blacklist line="blacklist ipv6" state="absent" create="yes"
when: disable_ipv6 == 'False'
# vim: set textwidth=0 ft=yaml ts=2 sw=2 expandtab: