Browse Source

Merge pull request #1 from nanowish/master

A few changes for common by nanowish
master
theonlydoo 9 years ago
parent
commit
e5944f55f7
5 changed files with 46 additions and 53 deletions
  1. +5
    -3
      host_vars/localhost.example
  2. +5
    -6
      postint.yml.README
  3. +4
    -1
      roles/common/handlers/main.yml
  4. +28
    -38
      roles/common/tasks/main.yml
  5. +4
    -5
      roles/common/templates/etc-ntp.conf.j2

etc/host_vars/localhost.example → host_vars/localhost.example View File

@ -1,9 +1,11 @@
---
---
admin_ssh_keys: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZXK3ufonx+zNQ1x6cSWuUWckB/xf9sKZ+mRgY5SPXzqrxSkqNSmr9JQ6xzvhxKEVcFWsi50op1WWtRo3HG3p3+EHKXeCyzt5QnczDlVOoQbB8kgI0byKcvXux1inL4/Q4DbVLUbDFnynD/C5aAyYMYePahMxR+AQr60DD+7Ty6pcEVih1wwHIlxWziY1EF6sEzQwz/PiTxWIZkKHl/WPGagS9Pp/5nQfdZy0AS/JqbzNyMEg51+XedADuqseV4GXDzrzDYLJXJFv1PFVJxRWLrjChKrUMqyszUySkZMr5YSPXlsV0bi+0xivYEsXvIkLORV96JTZosYbV+0aFKDPv root@debian admin_ssh_keys: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZXK3ufonx+zNQ1x6cSWuUWckB/xf9sKZ+mRgY5SPXzqrxSkqNSmr9JQ6xzvhxKEVcFWsi50op1WWtRo3HG3p3+EHKXeCyzt5QnczDlVOoQbB8kgI0byKcvXux1inL4/Q4DbVLUbDFnynD/C5aAyYMYePahMxR+AQr60DD+7Ty6pcEVih1wwHIlxWziY1EF6sEzQwz/PiTxWIZkKHl/WPGagS9Pp/5nQfdZy0AS/JqbzNyMEg51+XedADuqseV4GXDzrzDYLJXJFv1PFVJxRWLrjChKrUMqyszUySkZMr5YSPXlsV0bi+0xivYEsXvIkLORV96JTZosYbV+0aFKDPv root@debian
default_packages_debian: htop default_packages_debian: htop
description: machine test description: machine test
ntp_server1: 0.pool.ntp.org
ntp_server2: 1.pool.ntp.org
ntp_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
disable_ipv6: true disable_ipv6: true
domain: test.net domain: test.net
mariadb_version: 10.0 mariadb_version: 10.0

+ 5
- 6
postint.yml.README View File

@ -28,9 +28,9 @@ Après la description suivent des exemples de ces variables.
- default_packages_debian : la liste des packages debian a installer par defaut - default_packages_debian : la liste des packages debian a installer par defaut
- ansible_fqdn : le nom a donner au serveur - ansible_fqdn : le nom a donner au serveur
- description : La description du serveur (s'affichera a la connexion) - description : La description du serveur (s'affichera a la connexion)
- ntp_server1 : le premier serveur NTP a utiliser
- ntp_server2 : le deuxième serveur ntp a installer
- ntp_servers : liste de serveurs NTP à utiliser
- disable_ipv6 : IPv6 doit il etre desactive ou non - disable_ipv6 : IPv6 doit il etre desactive ou non
- tzdata_timezone: Permet de définir une timezone personnalisée (Europe/Paris est définie par défaut)
### Exemples de variables ### ### Exemples de variables ###
fichier : /etc/ansible/group_vars/all : fichier : /etc/ansible/group_vars/all :
@ -48,9 +48,8 @@ ansible_fqdn: serveur-debian.exemple.com
description: Bienvenue sur ce serveur debian description: Bienvenue sur ce serveur debian
ntp_server1: 0.fr.pool.ntp.org
ntp_server2: 1.fr.pool.ntp.org
ntp_servers:
- 0.fr.pool.ntp.org
- 1.fr.pool.ntp.org
disable_ipv6: yes disable_ipv6: yes

+ 4
- 1
roles/common/handlers/main.yml View File

@ -40,5 +40,8 @@
- name: apt-update - name: apt-update
command: apt-get update command: apt-get update
# vim: set textwidth=0 ft=yaml ts=2 sw=2 expandtab:
- name: update timezone
command: dpkg-reconfigure --frontend noninteractive tzdata
# vim: set textwidth=0 ft=yaml ts=2 sw=2 expandtab:

+ 28
- 38
roles/common/tasks/main.yml View File

@ -8,45 +8,39 @@
tags: bootstrap tags: bootstrap
raw: python -c "import apt" || DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y install python-apt raw: python -c "import apt" || DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y install python-apt
when: ansible_distribution == 'Debian' when: ansible_distribution == 'Debian'
# Check mandatory variables
- name: Check vars
# Check mandatory variables
- name: Check vars
fail: msg="Missing variable admin_ssh_keys" fail: msg="Missing variable admin_ssh_keys"
when: admin_ssh_keys is not defined when: admin_ssh_keys is not defined
- name: Check vars
- name: Check vars
fail: msg="Missing variable default_packages_debian" fail: msg="Missing variable default_packages_debian"
when: default_packages_debian is not defined when: default_packages_debian is not defined
- name: Check vars
- name: Check vars
fail: msg="Missing variable description" fail: msg="Missing variable description"
when: description is not defined when: description is not defined
- name: Check vars
fail: msg="Missing variable ntp_server1"
when: ntp_server1 is not defined
- name: Check vars
fail: msg="Missing variable ntp_server2"
when: ntp_server2 is not defined
- name: Check vars
fail: msg="Missing variable ntp_servers"
when: ntp_servers is not defined
- name: Check vars
- name: Check vars
fail: msg="Missing variable disable_ipv6" fail: msg="Missing variable disable_ipv6"
when: disable_ipv6 is not defined when: disable_ipv6 is not defined
# SSH # SSH
- name: Deploy SSH keys - name: Deploy SSH keys
tags: ssh_keys tags: ssh_keys
authorized_key: user=root key="{{item}}" authorized_key: user=root key="{{item}}"
with_items: "{{admin_ssh_keys}}"
with_items: admin_ssh_keys
# Packages # Packages
- name: Install default packages Debian. - name: Install default packages Debian.
apt: pkg={{item}} state=installed apt: pkg={{item}} state=installed
with_items: "{{ default_packages_debian }}"
with_items: default_packages_debian
when: ansible_distribution == 'Debian' when: ansible_distribution == 'Debian'
# Configure NTP # Configure NTP
@ -57,21 +51,18 @@
# Basic Shell & vim configuration # Basic Shell & vim configuration
- name: Custom .bashrc
tags: custom
copy: src=root-.bashrc dest=/root/.bashrc
- name: Custom .vimrc
tags: custom
copy: src=root-.vimrc dest=/root/.vimrc
- name: Custom .inputrc
tags: custom
copy: src=root-.inputrc dest=/root/.inputrc
- name: Create .vim/colors - name: Create .vim/colors
tags: custom tags: custom
file: path=/root/.vim/colors state=directory file: path=/root/.vim/colors state=directory
- name: Wombat vim colors theme is awesome
- name: Custom .bashrc, .vimrc, .inputrc and Wombat vim colors theme
tags: custom tags: custom
copy: src=root-.vim-colors-wombat.vim dest=/root/.vim/colors/wombat.vim
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 # Set motd and README.root
@ -79,13 +70,12 @@
tags: custom tags: custom
template: src=etc-motd.j2 dest=/etc/motd template: src=etc-motd.j2 dest=/etc/motd
- name: Modify /root/.profile
- name: Modify /root/.profile, Add basic README.root
tags: custom tags: custom
copy: src=root-.profile dest=/root/.profile
when: initialize == 'True'
- name: Add basic README.root
tags: custom
copy: src=root-README.root dest=/root/README.root
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' when: initialize == 'True'
# Env setup # Env setup
@ -97,11 +87,11 @@
debconf: name=locales question='locales/locales_to_be_generated' value='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' when: ansible_distribution == 'Debian'
- name: Set the timezone
tags: environ
debconf: name=tzdata question='tzdata/Zones/Etc' value='UTC' vtype='select'
debconf: name=tzdata question='tzdata/Areas' value='Europe' vtype='select'
debconf: name=tzdata question='tzdata/Zones/Europe' value='Paris' vtype='select'
- 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' when: ansible_distribution == 'Debian'
- name: Disable IPv6 (need reboot) - name: Disable IPv6 (need reboot)

+ 4
- 5
roles/common/templates/etc-ntp.conf.j2 View File

@ -6,12 +6,11 @@ statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable filegen clockstats file clockstats type day enable
server {{ ntp_server1 }}
server {{ ntp_server2 }}
{% for server in ntp_servers %}
server {{ server }}
restrict {{ server }} nomodify nopeer
{% endfor %}
restrict default ignore restrict default ignore
restrict -6 default ignore restrict -6 default ignore
restrict 127.0.0.1 restrict 127.0.0.1
restrict ::1 restrict ::1
restrict {{ ntp_server1 }} nomodify nopeer
restrict {{ ntp_server2 }} nomodify nopeer

Loading…
Cancel
Save