diff --git a/roles/client-install/meta/main.yml b/roles/client-install/meta/main.yml new file mode 100644 index 0000000..7ea21d9 --- /dev/null +++ b/roles/client-install/meta/main.yml @@ -0,0 +1,5 @@ +--- +dependencies: + - { role: pxe, tags: [ 'client-install' ] } + - { role: ubuntu-mirror, tags: [ 'client-install' ] } + - { role: mac2hostname, tags: [ 'client-install' ] } diff --git a/roles/mac2hostname/tasks/mac2hostname.yml b/roles/mac2hostname/tasks/mac2hostname.yml new file mode 100644 index 0000000..383d15d --- /dev/null +++ b/roles/mac2hostname/tasks/mac2hostname.yml @@ -0,0 +1,60 @@ +--- +# 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 diff --git a/roles/mac2hostname/tasks/main.yml b/roles/mac2hostname/tasks/main.yml index 383d15d..1aab2c2 100644 --- a/roles/mac2hostname/tasks/main.yml +++ b/roles/mac2hostname/tasks/main.yml @@ -1,60 +1,4 @@ --- -# 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 +- include: mac2hostname.yml + tags: + - "client-install" diff --git a/roles/nethcfg/tasks/main.yml b/roles/nethcfg/tasks/main.yml index 671ccf2..2b1a093 100644 --- a/roles/nethcfg/tasks/main.yml +++ b/roles/nethcfg/tasks/main.yml @@ -3,8 +3,14 @@ # Installo pacchetti addizionali - include: neth_pkgs.yml + tags: + - nethcfg - include: reconfig_nic.yml when: ansible_product_name == "VirtualBox" + tags: + - nethcfg - include: reconfig_srv.yml + tags: + - netcfg diff --git a/roles/pxe/tasks/main.yml b/roles/pxe/tasks/main.yml index 8ed3436..fdab152 100644 --- a/roles/pxe/tasks/main.yml +++ b/roles/pxe/tasks/main.yml @@ -1,141 +1,4 @@ --- -# Configurazione dell'ambiente di boot via rete per i client - -- name: Verifica configurazione tftp - shell: /sbin/e-smith/db configuration getprop dnsmasq dhcp-boot - register: chk_tftp_enabled - changed_when: "'pxelinux.0' not in chk_tftp_enabled.stdout" - ignore_errors: yes - sudo: yes - -- name: Configuro tftp - shell: /sbin/e-smith/db configuration setprop dnsmasq tftp-status enabled dhcp-boot pxelinux.0 - when: chk_tftp_enabled|changed - sudo: yes - -- name: Attivo tftp - shell: /sbin/e-smith/signal-event nethserver-dnsmasq-save - when: chk_tftp_enabled|changed - sudo: yes - -- name: Verifica configurazione ibay kickstart - shell: /sbin/e-smith/db accounts show ks - register: chk_ks_created - changed_when: chk_ks_created.rc != 0 - ignore_errors: yes - sudo: yes - -- name: Configurazione web kickstart - shell: /sbin/e-smith/db accounts set ks ibay Description "Kickstart share" GroupAccess rw HttpAccess private HttpAliasType default HttpAllowOverrideStatus disabled HttpForceSslStatus disabled HttpPasswordStatus disabled HttpStatus enabled HttpVirtualHost __ANY__ OtherAccess r OwningGroup locals SmbAuditStatus disabled SmbStatus disabled - when: chk_ks_created|failed - sudo: yes - -- name: Attivazione web kickstart - shell: /sbin/e-smith/signal-event ibay-create ks - when: chk_ks_created|failed - sudo: yes - -- name: Verifica presenza directory mirror - file: path=/var/spool/apt-mirror/mirror state=directory - register: chk_mirror_dir - ignore_errors: yes - sudo: yes - -- name: Collegamento directory mirror - file: path=/var/lib/nethserver/ibay/ks/mirror src=/var/spool/apt-mirror/mirror state=link - sudo: yes - when: chk_mirror_dir|success - -- name: Creo directory necessarie - file: path={{ item }} state=directory - with_items: - - /var/lib/tftpboot/pxelinux.cfg - - /var/lib/tftpboot/ubuntu/14.04/i386 - - /var/lib/tftpboot/ubuntu/14.04/amd64 - - /var/lib/tftpboot/utils/memtest86 - sudo: yes - -- name: pxelinux.0 - get_url: - url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/pxelinux.0 - dest: /var/lib/tftpboot/pxelinux.0 - sudo: yes - -- name: pxelinux.cfg/default - template: src=pxelinux.cfg/default dest=/var/lib/tftpboot/pxelinux.cfg/default - sudo: yes - -- name: bglug.png - copy: src=bglug.png dest=/var/lib/tftpboot/utils/bglug.png - sudo: yes - -- name: vesamenu.c32 - get_url: - url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/ubuntu-installer/i386/boot-screens/vesamenu.c32 - dest: /var/lib/tftpboot/utils/vesamenu.c32 - sudo: yes - -- name: linux i386 - get_url: - url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/ubuntu-installer/i386/linux - dest: /var/lib/tftpboot/ubuntu/14.04/i386/linux - sudo: yes - -- name: initrd.gz i386 - get_url: - url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/ubuntu-installer/i386/initrd.gz - dest: /var/lib/tftpboot/ubuntu/14.04/i386/initrd.gz - sudo: yes - -- name: linux amd64 - get_url: - url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux - dest: /var/lib/tftpboot/ubuntu/14.04/amd64/linux - sudo: yes - -- name: initrd.gz amd64 - get_url: - url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz - dest: /var/lib/tftpboot/ubuntu/14.04/amd64/initrd.gz - sudo: yes - -- name: memdisk - get_url: - url: http://syntaxerrormmm.zapto.org/pxe-bootimg/memdisk - dest: /var/lib/tftpboot/utils/memdisk - sudo: yes - -- name: memtest86 - get_url: - url: http://syntaxerrormmm.zapto.org/pxe-bootimg/memtest86/vmlinuz - dest: /var/lib/tftpboot/utils/memtest86/vmlinuz - sudo: yes - -- name: hdt - get_url: - url: http://syntaxerrormmm.zapto.org/pxe-bootimg/hdt.img - dest: /var/lib/tftpboot/utils/hdt.img - sudo: yes - -- name: Sovrascrivo la variabile mirrorpath se è su Virtualbox - set_fact: oldmirrorpath="{{ mirrorpath }}" mirrorpath="" - when: ansible_bios_version == "VirtualBox" - -- name: Copia configurazioni kickstart - template: src=ks/{{ item }} dest=/var/lib/nethserver/ibay/ks/{{ item }} - sudo: yes - with_items: - - client-trusty.cfg - - docenti-trusty.cfg - - ubuntu-trusty.cfg - - post-ks.sh - - ansible-pull.sh - - ansible-pull-crontab - -- name: Copio logrotate per configurazione pull - copy: src=ansible-pull-logrotate dest=/var/lib/nethserver/ibay/ks/ansible-pull-logrotate - sudo: yes - -- name: Ripristino impostazioni mirrorpath - set_fact: mirrorpath="{{ oldmirrorpath }}" - when: ansible_bios_version == "VirtualBox" +- include: pxe.yml + tags: + - "client-install" diff --git a/roles/pxe/tasks/pxe.yml b/roles/pxe/tasks/pxe.yml new file mode 100644 index 0000000..8ed3436 --- /dev/null +++ b/roles/pxe/tasks/pxe.yml @@ -0,0 +1,141 @@ +--- +# Configurazione dell'ambiente di boot via rete per i client + +- name: Verifica configurazione tftp + shell: /sbin/e-smith/db configuration getprop dnsmasq dhcp-boot + register: chk_tftp_enabled + changed_when: "'pxelinux.0' not in chk_tftp_enabled.stdout" + ignore_errors: yes + sudo: yes + +- name: Configuro tftp + shell: /sbin/e-smith/db configuration setprop dnsmasq tftp-status enabled dhcp-boot pxelinux.0 + when: chk_tftp_enabled|changed + sudo: yes + +- name: Attivo tftp + shell: /sbin/e-smith/signal-event nethserver-dnsmasq-save + when: chk_tftp_enabled|changed + sudo: yes + +- name: Verifica configurazione ibay kickstart + shell: /sbin/e-smith/db accounts show ks + register: chk_ks_created + changed_when: chk_ks_created.rc != 0 + ignore_errors: yes + sudo: yes + +- name: Configurazione web kickstart + shell: /sbin/e-smith/db accounts set ks ibay Description "Kickstart share" GroupAccess rw HttpAccess private HttpAliasType default HttpAllowOverrideStatus disabled HttpForceSslStatus disabled HttpPasswordStatus disabled HttpStatus enabled HttpVirtualHost __ANY__ OtherAccess r OwningGroup locals SmbAuditStatus disabled SmbStatus disabled + when: chk_ks_created|failed + sudo: yes + +- name: Attivazione web kickstart + shell: /sbin/e-smith/signal-event ibay-create ks + when: chk_ks_created|failed + sudo: yes + +- name: Verifica presenza directory mirror + file: path=/var/spool/apt-mirror/mirror state=directory + register: chk_mirror_dir + ignore_errors: yes + sudo: yes + +- name: Collegamento directory mirror + file: path=/var/lib/nethserver/ibay/ks/mirror src=/var/spool/apt-mirror/mirror state=link + sudo: yes + when: chk_mirror_dir|success + +- name: Creo directory necessarie + file: path={{ item }} state=directory + with_items: + - /var/lib/tftpboot/pxelinux.cfg + - /var/lib/tftpboot/ubuntu/14.04/i386 + - /var/lib/tftpboot/ubuntu/14.04/amd64 + - /var/lib/tftpboot/utils/memtest86 + sudo: yes + +- name: pxelinux.0 + get_url: + url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/pxelinux.0 + dest: /var/lib/tftpboot/pxelinux.0 + sudo: yes + +- name: pxelinux.cfg/default + template: src=pxelinux.cfg/default dest=/var/lib/tftpboot/pxelinux.cfg/default + sudo: yes + +- name: bglug.png + copy: src=bglug.png dest=/var/lib/tftpboot/utils/bglug.png + sudo: yes + +- name: vesamenu.c32 + get_url: + url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/ubuntu-installer/i386/boot-screens/vesamenu.c32 + dest: /var/lib/tftpboot/utils/vesamenu.c32 + sudo: yes + +- name: linux i386 + get_url: + url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/ubuntu-installer/i386/linux + dest: /var/lib/tftpboot/ubuntu/14.04/i386/linux + sudo: yes + +- name: initrd.gz i386 + get_url: + url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/ubuntu-installer/i386/initrd.gz + dest: /var/lib/tftpboot/ubuntu/14.04/i386/initrd.gz + sudo: yes + +- name: linux amd64 + get_url: + url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux + dest: /var/lib/tftpboot/ubuntu/14.04/amd64/linux + sudo: yes + +- name: initrd.gz amd64 + get_url: + url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz + dest: /var/lib/tftpboot/ubuntu/14.04/amd64/initrd.gz + sudo: yes + +- name: memdisk + get_url: + url: http://syntaxerrormmm.zapto.org/pxe-bootimg/memdisk + dest: /var/lib/tftpboot/utils/memdisk + sudo: yes + +- name: memtest86 + get_url: + url: http://syntaxerrormmm.zapto.org/pxe-bootimg/memtest86/vmlinuz + dest: /var/lib/tftpboot/utils/memtest86/vmlinuz + sudo: yes + +- name: hdt + get_url: + url: http://syntaxerrormmm.zapto.org/pxe-bootimg/hdt.img + dest: /var/lib/tftpboot/utils/hdt.img + sudo: yes + +- name: Sovrascrivo la variabile mirrorpath se è su Virtualbox + set_fact: oldmirrorpath="{{ mirrorpath }}" mirrorpath="" + when: ansible_bios_version == "VirtualBox" + +- name: Copia configurazioni kickstart + template: src=ks/{{ item }} dest=/var/lib/nethserver/ibay/ks/{{ item }} + sudo: yes + with_items: + - client-trusty.cfg + - docenti-trusty.cfg + - ubuntu-trusty.cfg + - post-ks.sh + - ansible-pull.sh + - ansible-pull-crontab + +- name: Copio logrotate per configurazione pull + copy: src=ansible-pull-logrotate dest=/var/lib/nethserver/ibay/ks/ansible-pull-logrotate + sudo: yes + +- name: Ripristino impostazioni mirrorpath + set_fact: mirrorpath="{{ oldmirrorpath }}" + when: ansible_bios_version == "VirtualBox" diff --git a/roles/ubuntu-mirror/tasks/main.yml b/roles/ubuntu-mirror/tasks/main.yml index 6862b75..67a5efc 100644 --- a/roles/ubuntu-mirror/tasks/main.yml +++ b/roles/ubuntu-mirror/tasks/main.yml @@ -1,10 +1,4 @@ --- -# Configurazione del server come repo - -- name: Installazione apt-mirror - yum: pkg=apt-mirror state=present - sudo: yes - -- name: Installazione configurazione apt-mirror - copy: src=apt-mirror.list dest=/etc/apt-mirror.list - sudo: yes +- include: ubuntu-mirror.yml + tags: + - "client-install" diff --git a/roles/ubuntu-mirror/tasks/ubuntu-mirror.yml b/roles/ubuntu-mirror/tasks/ubuntu-mirror.yml new file mode 100644 index 0000000..6862b75 --- /dev/null +++ b/roles/ubuntu-mirror/tasks/ubuntu-mirror.yml @@ -0,0 +1,10 @@ +--- +# Configurazione del server come repo + +- name: Installazione apt-mirror + yum: pkg=apt-mirror state=present + sudo: yes + +- name: Installazione configurazione apt-mirror + copy: src=apt-mirror.list dest=/etc/apt-mirror.list + sudo: yes diff --git a/setup.yml b/setup.yml index 793b6b1..dd37b8e 100644 --- a/setup.yml +++ b/setup.yml @@ -6,3 +6,4 @@ roles: - setup - nethcfg + - client-install diff --git a/sr-nethconfig.yml b/sr-nethconfig.yml deleted file mode 100644 index 40cbc4d..0000000 --- a/sr-nethconfig.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- hosts: server - vars_files: - - domain.yml - roles: - - nethcfg diff --git a/sr-pxe.yml b/sr-pxe.yml deleted file mode 100644 index 750e2a1..0000000 --- a/sr-pxe.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- hosts: server - vars_files: - - domain.yml - roles: - - pxe - - ubuntu-mirror - - mac2hostname