Using variables from domain.fact instead of local domain.yml. Managed in a different manner the different settings for the ubuntu mirror from VirtualBox and local server.

This commit is contained in:
Emiliano Vavassori 2015-07-22 00:24:00 +02:00
parent 7e62958a19
commit c956f21343
14 changed files with 44 additions and 42 deletions

View File

@ -1,6 +1,5 @@
---
dependencies:
- { role: domaininfo, tags: [ 'client-install', 'domaininfo' ] }
- { role: pxe, tags: [ 'client-install', 'pxe' ] }
- { role: kickstart, tags: [ 'client-install', 'kickstart', 'ks' ] }
- { role: ubuntu-mirror, tags: [ 'client-install', 'ubuntu-mirror' ] }

View File

@ -4,6 +4,10 @@
copy: src=../../../domain.yml dest=/etc/domain.yml
sudo: yes
- name: Utilizzo un piccolo wrapper per passare come fatti informazioni di dominio
copy: src=domain.fact dest=/etc/ansible/fact.d/domain.fact mode=0744 owner=root
- name: Creo la cartella per le configurazioni di Ansible
file: path=/etc/ansible/facts.d state=directory owner=root mode=0755
sudo: yes
- name: Utilizzo un piccolo wrapper per passare come fatti informazioni di dominio
copy: src=domain.fact dest=/etc/ansible/facts.d/domain.fact mode=0755 owner=root
sudo: yes

View File

@ -31,10 +31,15 @@
file: path=/var/lib/nethserver/ibay/ks/profiles state=directory
sudo: yes
- name: Sovrascrivo la variabile mirrorpath se è su Virtualbox
set_fact: oldmirrorpath="{{ mirrorpath }}" mirrorpath=""
# Gestisco caso con virtualbox, dove non devo overridare il mirror
- name: ubuntumirrorpath per Virtualbox (no mirror)
set_fact: ubuntumirrorpath=""
when: ansible_bios_version == "VirtualBox"
- name: ubuntumirrorpath per altro (usa mirror locale)
set_fact: ubuntumirrorpath="{{ ansible_local.domain.mirrorpath }}"
when: ansible_bios_version != "VirtualBox"
- name: Copia profili kickstart
template: src=profiles/{{ item }} dest=/var/lib/nethserver/ibay/ks/profiles/{{ item }}
sudo: yes
@ -52,10 +57,6 @@
- ansible-pull.sh
- ansible-pull-crontab
- name: Ripristino impostazioni mirrorpath
set_fact: mirrorpath="{{ oldmirrorpath }}"
when: ansible_bios_version == "VirtualBox"
- name: Copio logrotate per configurazione pull
copy: src=ansible-pull-logrotate dest=/var/lib/nethserver/ibay/ks/ansible-pull-logrotate
sudo: yes

View File

@ -1 +1 @@
@reboot root /var/lib/{{ domainfull }}/bin/ansible-pull.sh >>/var/log/ansible-pull.log 2>&1
@reboot root /var/lib/{{ ansible_local.domain.domainfull }}/bin/ansible-pull.sh >>/var/log/ansible-pull.log 2>&1

View File

@ -4,13 +4,13 @@
# Potremmo decidere di far eseguire uno script generato da servizio
# domainhelper contenente anche l'eventuale branch da usare.
url=git://{{ serverfqdn }}/client-pull-installation.git
repo=/var/lib/{{ domainfull }}/config
url=git://{{ ansible_local.domain.serverfqdn }}/client-pull-installation.git
repo=/var/lib/{{ ansible_local.domain.domainfull }}/config
logfile=/var/lib/ansible-pull.log
branch=master
playbook=local.yml
vaultpassfile=$(/var/lib/{{ domainfull }}/bin/getvaultpass.py)
vaultpassfile=$(/var/lib/{{ ansible_local.domain.domainfull }}/bin/getvaultpass.py)
ansible-pull --accept-host-key -d "${repo}" -U "${url}" -C "${branch}" "${playbook}" --vault-password-file "${vaultpassfile}"
rm -f "${vaultpassfile}"

View File

@ -11,7 +11,7 @@ import os
key = MD5.new(gethostname()).digest()
cipher = AES.new(key, AES.MODE_ECB)
base64enc = get("http://{{ serverfqdn }}:3000/vaultpass")
base64enc = get("http://{{ ansible_local.domain.serverfqdn }}:3000/vaultpass")
encrypted = b64decode(base64enc.content)
longpass = cipher.decrypt(encrypted)

View File

@ -1,35 +1,35 @@
#!/bin/bash
# Cambio username con quello fornito da servizio
TARGETHOSTNAME=$(wget -qO- http://{{ serverfqdn }}:3000/whatsmyhostname)
TARGETHOSTNAME=$(wget -qO- http://{{ ansible_local.domain.serverfqdn }}:3000/whatsmyhostname)
echo $TARGETHOSTNAME > /etc/hostname
sed -i "s/kickseed/$TARGETHOSTNAME/g" /etc/hosts
# Installo l'ultimo ansible per ansible-pull
export https_proxy=https://{{ serverip }}:3128
export https_proxy=https://{{ ansible_local.domain.serverip }}:3128
add-apt-repository -y ppa:ansible/ansible
apt-get update && apt-get install -y ansible
unset https_proxy
# Creo directory dipendenti
install -d -o root -g root /var/lib/{{ domainfull }}/config
install -d -o root -g root /var/lib/{{ domainfull }}/bin
install -d -o root -g root /var/lib/{{ ansible_local.domain.domainfull }}/config
install -d -o root -g root /var/lib/{{ ansible_local.domain.domainfull }}/bin
# Installo lo script per la decrittazione della password del vault
wget -q http://{{ serverfqdn }}/ks/getvaultpass.py -O /tmp/getvaultpass.py
install -m744 -o root -g root /tmp/getvaultpass.py /var/lib/{{ domainfull}}/bin/getvaultpass.py
wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/getvaultpass.py -O /tmp/getvaultpass.py
install -m744 -o root -g root /tmp/getvaultpass.py /var/lib/{{ ansible_local.domain.domainfull}}/bin/getvaultpass.py
rm -f /tmp/getvaultpass.py
# Installo lo script per l'avvio di ansible-pull da root
wget -q http://{{ serverfqdn }}/ks/ansible-pull.sh -O /tmp/ansible-pull.sh
install -m744 -o root -g root /tmp/ansible-pull.sh /var/lib/{{ domainfull }}/bin/ansible-pull.sh
wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/ansible-pull.sh -O /tmp/ansible-pull.sh
install -m744 -o root -g root /tmp/ansible-pull.sh /var/lib/{{ ansible_local.domain.domainfull }}/bin/ansible-pull.sh
rm -f /tmp/ansible-pull.sh
# Installo il cronjob
wget -q http://{{ serverfqdn }}/ks/ansible-pull-crontab -O /tmp/ansible-pull-crontab
wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/ansible-pull-crontab -O /tmp/ansible-pull-crontab
install -m644 -o root -g root /tmp/ansible-pull-crontab /etc/cron.d/ansible-pull
rm -f /tmp/ansible-pull-crontab
# Installo il logrotate
wget -q http://{{ serverfqdn }}/ks/ansible-pull-logrotate -O /tmp/ansible-pull-logrotate
wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/ansible-pull-logrotate -O /tmp/ansible-pull-logrotate
install -m644 -o root -g root /tmp/ansible-pull-logrotate /etc/logrotate.d/ansible
rm -f /tmp/ansible-pull-logrotate

View File

@ -20,7 +20,7 @@ text
install
#Use Web installation
#url --url http://archive.ubuntu.com/ubuntu
url --url http://{{ mirrorpath }}archive.ubuntu.com/ubuntu
url --url http://{{ ubuntumirrorpath }}archive.ubuntu.com/ubuntu
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
@ -61,4 +61,4 @@ sshpass
#Post installation commands
%post
#the target filesystem in nochroot environment is in /target
\curl -sSL http://{{ serverfqdn }}/ks/post-ks.sh | bash >/root/post-ks.log 2>&1
\curl -sSL http://{{ ansible_local.domain.serverfqdn }}/ks/post-ks.sh | bash >/root/post-ks.log 2>&1

View File

@ -20,7 +20,7 @@ text
install
#Use Web installation
#url --url http://archive.ubuntu.com/ubuntu
url --url http://{{ mirrorpath }}archive.ubuntu.com/ubuntu
url --url http://{{ ubuntumirrorpath }}archive.ubuntu.com/ubuntu
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
@ -52,6 +52,6 @@ openssh-server
#Post installation commands
%post --nochroot
#the target filesystem in nochroot environment is in /target
TARGETHOSTNAME=$(wget -qO- http://{{ serverfqdn }}:3000/whatsmyhostname)
TARGETHOSTNAME=$(wget -qO- http://{{ ansible_local.domain.serverfqdn }}:3000/whatsmyhostname)
echo $TARGETHOSTNAME > /target/etc/hostname
sed -i "s/kickseed/$TARGETHOSTNAME/g" /target/etc/hosts

View File

@ -20,7 +20,7 @@ text
install
#Use Web installation
#url --url http://archive.ubuntu.com/ubuntu
url --url http://archive.ubuntu.com/ubuntu
url --url http://{{ ubuntumirrorpath }}archive.ubuntu.com/ubuntu
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
@ -47,6 +47,6 @@ openssh-server
#Post installation commands
%post --nochroot
#the target filesystem in nochroot environment is in /target
TARGETHOSTNAME=$(wget -qO- http://{{ serverfqdn }}:3000/whatsmyhostname)
TARGETHOSTNAME=$(wget -qO- http://{{ ansible_local.domain.serverfqdn }}:3000/whatsmyhostname)
echo $TARGETHOSTNAME > /target/etc/hostname
sed -i "s/kickseed/$TARGETHOSTNAME/g" /target/etc/hosts

View File

@ -3,7 +3,7 @@
sudo: yes
- name: Configurazione scheda di rete interna
shell: /sbin/e-smith/db networks setprop eth1 role green ipaddr {{ serverip }} netmask {{ servernetmask }}
shell: /sbin/e-smith/db networks setprop eth1 role green ipaddr {{ ansible_local.domain.serverip }} netmask {{ ansible_local.domain.servernetmask }}
sudo: yes
- name: Attivo configurazioni di rete
@ -11,7 +11,7 @@
sudo: yes
- name: Configurazione rete trusted
shell: /sbin/e-smith/db networks set {{ servernet }} network Description "Local LAN" Mask {{ servernetmask }}
shell: /sbin/e-smith/db networks set {{ ansible_local.domain.servernet }} network Description "Local LAN" Mask {{ ansible_local.domain.servernetmask }}
sudo: yes
- name: Modifico configurazioni

View File

@ -1,14 +1,14 @@
---
- name: Configurazione organizzazione
shell: /sbin/e-smith/db configuration setprop OrganizationContact City "{{ org_city }}" Company "{{ org_company }}" CountryCode {{ org_countrycode }} Department "{{ org_department }}" PhoneNumber "{{ org_phone }}" Street "{{ org_street }}"
shell: /sbin/e-smith/db configuration setprop OrganizationContact City "{{ ansible_local.domain.org_city }}" Company "{{ ansible_local.domain.org_company }}" CountryCode {{ ansible_local.domain.org_countrycode }} Department "{{ ansible_local.domain.org_department }}" PhoneNumber "{{ ansible_local.domain.org_phone }}" Street "{{ ansible_local.domain.org_street }}"
sudo: yes
- name: Configurazione nome server
shell: /sbin/e-smith/db configuration set SystemName {{ server }}
shell: /sbin/e-smith/db configuration set SystemName {{ ansible_local.domain.server }}
sudo: yes
- name: Configurazione nome dominio
shell: /sbin/e-smith/db configuration set DomainName {{ domainfull }}
shell: /sbin/e-smith/db configuration set DomainName {{ ansible_local.domain.domainfull }}
sudo: yes
- name: Attivazione cambiamenti hostname
@ -24,7 +24,7 @@
sudo: yes
- name: Configurazione servizio DHCP
shell: /sbin/e-smith/db dhcp set eth1 range DhcpRangeStart {{ dhcprange_start }} DhcpRangeEnd {{ dhcprange_end }} status enabled
shell: /sbin/e-smith/db dhcp set eth1 range DhcpRangeStart {{ ansible_local.domain.dhcprange_start }} DhcpRangeEnd {{ ansible_local.domain.dhcprange_end }} status enabled
sudo: yes
- name: Attivazione configurazione DHCP
@ -32,7 +32,7 @@
sudo: yes
- name: Configurazione servizio DNS
shell: /sbin/e-smith/db configuration setprop dns role resolver NameServers "{{ extdnsserver1 }},{{ extdnsserver2 }}"
shell: /sbin/e-smith/db configuration setprop dns role resolver NameServers "{{ ansible_local.domain.extdnsserver1 }},{{ ansible_local.domain.extdnsserver2 }}"
sudo: yes
register: cfg_dns
@ -50,7 +50,7 @@
sudo: yes
- name: Configurazione SMB
shell: /sbin/e-smith/db configuration setprop smb RoamingProfiles yes ServerRole PDC Workgroup "{{ domainshort }}" status enabled
shell: /sbin/e-smith/db configuration setprop smb RoamingProfiles yes ServerRole PDC Workgroup "{{ ansible_local.domain.domainshort }}" status enabled
sudo: yes
- name: Attivo configurazione SMB

View File

@ -9,13 +9,13 @@ LABEL client
MENU LABEL Installa nuova macchina CLIENT
LINUX /ubuntu/14.04/amd64/linux
INITRD /ubuntu/14.04/amd64/initrd.gz
APPEND vga=normal ks=http://{{ serverfqdn }}/ks/profiles/client-trusty.cfg -- quiet
APPEND vga=normal ks=http://{{ ansible_local.domain.serverfqdn }}/ks/profiles/client-trusty.cfg -- quiet
LABEL docenti
MENU LABEL Installa nuova macchina DOCENTI
LINUX /ubuntu/14.04/amd64/linux
INITRD /ubuntu/14.04/amd64/initrd.gz
APPEND vga=normal ks=http://{{ serverfqdn }}/ks/profiles/docenti-trusty.cfg -- quiet
APPEND vga=normal ks=http://{{ ansible_local.domain.serverfqdn }}/ks/profiles/docenti-trusty.cfg -- quiet
MENU SEPARATOR

View File

@ -1,8 +1,6 @@
---
- hosts: server
vars_files:
- domain.yml
roles:
- setup
- nethcfg