Inserimento di doraemon al posto di mac2hostname e ansiblehelper. Modifica script per creazione, in fase di prima installazione, della password del vault.
This commit is contained in:
parent
56f92ba8f0
commit
0faf2f2ef4
@ -1,59 +0,0 @@
|
||||
---
|
||||
# Installa e configura il servizio per aiutare ansible-pull
|
||||
|
||||
- name: Installazione dipendenze Python
|
||||
yum: pkg=python-bottle state=present
|
||||
sudo: yes
|
||||
|
||||
- name: Check installazione + versione ansiblehelper
|
||||
shell: rpm -q ansiblehelper
|
||||
ignore_errors: yes
|
||||
register: check_ansiblehelper_pkg
|
||||
changed_when: check_ansiblehelper_pkg.rc != 0 or check_ansiblehelper_pkg.stdout.find('1.0.0-1') == -1
|
||||
|
||||
- name: Installazione ansiblehelper
|
||||
yum: pkg=http://syntaxerrormmm.zapto.org/downloads/rpm/ansiblehelper-1.0.0-1.el6.noarch.rpm state=present
|
||||
when: check_ansiblehelper_pkg|changed
|
||||
sudo: yes
|
||||
|
||||
- name: Verifica aggiunta servizi
|
||||
shell: /sbin/e-smith/db configuration show ansiblehelper
|
||||
sudo: yes
|
||||
register: chk_ansiblehelper_srv
|
||||
changed_when: chk_ansiblehelper_srv.rc != 0
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Aggiungo il servizio ai servizi gestiti da NethServer
|
||||
shell: /sbin/e-smith/db configuration set ansiblehelper service status enabled TCPPort 3001 access private
|
||||
sudo: yes
|
||||
when: chk_ansiblehelper_srv|changed
|
||||
|
||||
- name: Default per NetServer - Cartella defaults
|
||||
shell: mkdir -p /etc/e-smith/db/configuration/defaults/ansiblehelper
|
||||
sudo: yes
|
||||
when: chk_ansiblehelper_srv|changed
|
||||
|
||||
- name: Default per NethServer - Tipo
|
||||
shell: echo "service" > /etc/e-smith/db/configuration/defaults/ansiblehelper/type
|
||||
sudo: yes
|
||||
when: chk_ansiblehelper_srv|changed
|
||||
|
||||
- name: Default per NethServer - Stato
|
||||
shell: echo "enabled" > /etc/e-smith/db/configuration/defaults/ansiblehelper/status
|
||||
sudo: yes
|
||||
when: chk_ansiblehelper_srv|changed
|
||||
|
||||
- name: Aggiunta servizio
|
||||
shell: /sbin/e-smith/signal-event runlevel-adjust
|
||||
sudo: yes
|
||||
when: chk_ansiblehelper_srv|changed
|
||||
|
||||
- name: Aggiunta servizio di rete e cambio firewall
|
||||
shell: /sbin/e-smith/signal-event firewall-adjust
|
||||
sudo: yes
|
||||
when: chk_ansiblehelper_srv|changed
|
||||
|
||||
- name: Avvio di ansiblehelper
|
||||
shell: service ansiblehelper start
|
||||
sudo: yes
|
||||
when: chk_ansiblehelper_srv|changed
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
- include: ansiblehelper.yml
|
||||
tags: ansiblehelper
|
@ -2,6 +2,5 @@
|
||||
dependencies:
|
||||
- { role: pxe, tags: [ 'client-install', 'pxe' ] }
|
||||
- { role: ubuntu-mirror, tags: [ 'client-install', 'ubuntu-mirror' ] }
|
||||
- { role: mac2hostname, tags: [ 'client-install', 'mac2hostname' ] }
|
||||
- { role: doraemon, tags: [ 'client-install', 'doraemon' ] }
|
||||
- { role: git-daemon, tags: [ 'client-install', 'git-daemon' ] }
|
||||
- { role: ansiblehelper, tags: [ 'client-install', 'ansiblehelper' ] }
|
||||
|
14
roles/doraemon/tasks/doraemon.yml
Normal file
14
roles/doraemon/tasks/doraemon.yml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
# Installa e configura il servizio per rinominare il client
|
||||
# Grazie per il servizio a Enrico Bacis
|
||||
|
||||
- name: Check installazione + versione doraemon
|
||||
shell: rpm -q doraemon
|
||||
ignore_errors: yes
|
||||
register: check_doraemon_pkg
|
||||
changed_when: check_doraemon_pkg.rc != 0 or check_doraemon_pkg.stdout.find('1.0.0-1') == -1
|
||||
|
||||
- name: Installazione doraemon
|
||||
yum: pkg=http://syntaxerrormmm.zapto.org/downloads/rpm/doraemon-1.0.0-1.ns6.noarch.rpm state=present
|
||||
when: check_doraemon_pkg|changed
|
||||
sudo: yes
|
@ -1,4 +1,4 @@
|
||||
---
|
||||
- include: mac2hostname.yml
|
||||
- include: doraemon.yml
|
||||
tags:
|
||||
- "client-install"
|
@ -1,60 +0,0 @@
|
||||
---
|
||||
# Installa e configura il servizio per rinominare il client
|
||||
# Grazie per il servizio a Enrico Bacis
|
||||
|
||||
- name: Installazione dipendenze Python
|
||||
yum: pkg=python-bottle state=present
|
||||
sudo: yes
|
||||
|
||||
- name: Check installazione + versione mac2hostname
|
||||
shell: rpm -q mac2hostname
|
||||
ignore_errors: yes
|
||||
register: check_mac2hostname_pkg
|
||||
changed_when: check_mac2hostname_pkg.rc != 0 or check_mac2hostname_pkg.stdout.find('2.0.0-1') == -1
|
||||
|
||||
- name: Installazione mac2hostname
|
||||
yum: pkg=http://syntaxerrormmm.zapto.org/downloads/rpm/mac2hostname-2.0.0-1.el6.noarch.rpm state=present
|
||||
when: check_mac2hostname_pkg|changed
|
||||
sudo: yes
|
||||
|
||||
- name: Verifica aggiunta servizi
|
||||
shell: /sbin/e-smith/db configuration show mac2hostname
|
||||
sudo: yes
|
||||
register: chk_mac2hostname_srv
|
||||
changed_when: chk_mac2hostname_srv.rc != 0
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Aggiungo il servizio ai servizi gestiti da NethServer
|
||||
shell: /sbin/e-smith/db configuration set mac2hostname service status enabled TCPPort 3000 access private
|
||||
sudo: yes
|
||||
when: chk_mac2hostname_srv|changed
|
||||
|
||||
- name: Default per NetServer - Cartella defaults
|
||||
shell: mkdir -p /etc/e-smith/db/configuration/defaults/mac2hostname
|
||||
sudo: yes
|
||||
when: chk_mac2hostname_srv|changed
|
||||
|
||||
- name: Default per NethServer - Tipo
|
||||
shell: echo "service" > /etc/e-smith/db/configuration/defaults/mac2hostname/type
|
||||
sudo: yes
|
||||
when: chk_mac2hostname_srv|changed
|
||||
|
||||
- name: Default per NethServer - Stato
|
||||
shell: echo "enabled" > /etc/e-smith/db/configuration/defaults/mac2hostname/status
|
||||
sudo: yes
|
||||
when: chk_mac2hostname_srv|changed
|
||||
|
||||
- name: Aggiunta servizio
|
||||
shell: /sbin/e-smith/signal-event runlevel-adjust
|
||||
sudo: yes
|
||||
when: chk_mac2hostname_srv|changed
|
||||
|
||||
- name: Aggiunta servizio di rete e cambio firewall
|
||||
shell: /sbin/e-smith/signal-event firewall-adjust
|
||||
sudo: yes
|
||||
when: chk_mac2hostname_srv|changed
|
||||
|
||||
- name: Avvio di mac2hostname
|
||||
shell: service mac2hostname start
|
||||
sudo: yes
|
||||
when: chk_mac2hostname_srv|changed
|
@ -129,6 +129,7 @@
|
||||
- docenti-trusty.cfg
|
||||
- ubuntu-trusty.cfg
|
||||
- post-ks.sh
|
||||
- getvaultpass.py
|
||||
- ansible-pull.sh
|
||||
- ansible-pull-crontab
|
||||
|
||||
|
@ -10,4 +10,4 @@ logfile=/var/lib/ansible-pull.log
|
||||
branch=master
|
||||
playbook=local.yml
|
||||
|
||||
ansible-pull --accept-host-key -d "${repo}" -U "${url}" -C "${branch}" "${playbook}"
|
||||
ansible-pull --accept-host-key -d "${repo}" -U "${url}" -C "${branch}" "${playbook}" --vault-password-file "/root/.ansible/vault.txt"
|
||||
|
21
roles/pxe/templates/ks/getvaultpass.py
Normal file
21
roles/pxe/templates/ks/getvaultpass.py
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Crypto.Hash import MD5
|
||||
from Crypto.Cipher import AES
|
||||
from base64 import b64decode
|
||||
from requests import get
|
||||
from socket import gethostname
|
||||
from os import makedirs, path
|
||||
|
||||
key = MD5.new(gethostname()).digest()
|
||||
cipher = AES.new(key, AES.MODE_ECB)
|
||||
base64enc = get("http://{{ serverfqdn }}:3000/vaultpass")
|
||||
encrypted = b64decode(base64enc)
|
||||
longpass = cipher.decrypt(encrypted)
|
||||
|
||||
if not path.exists('/root/.ansible'):
|
||||
makedirs('/root/.ansible')
|
||||
|
||||
with open('/root/.ansible/vault.txt', 'w') as vaultfile:
|
||||
vaultfile.write(longpass.strip('x'))
|
@ -15,6 +15,10 @@ unset https_proxy
|
||||
install -d -o root -g root /var/lib/{{ domainfull }}/config
|
||||
install -d -o root -g root /var/lib/{{ domainfull }}/bin
|
||||
|
||||
# Installo lo script per la decrittazione della password del vault
|
||||
wget -q http://{{ serverfqdn }}/ks/getvaultpass.py -O /tmp/getvaultpass.py
|
||||
python /tmp/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
|
||||
|
Loading…
x
Reference in New Issue
Block a user