From c587b66ee09b073af44723b667e468fe6083121e Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Tue, 12 Jan 2016 22:03:15 +0100 Subject: [PATCH] Migrating sudo ansible syntax to 'become', sudo will be obsoleted in 2.2. --- roles/ansible-pull/tasks/ansible-pull.yml | 6 +- roles/developuser/tasks/developuser.yml | 10 +-- roles/doraemon/tasks/doraemon.yml | 4 +- roles/git-daemon/tasks/git-daemon.yml | 46 +++++----- roles/init/tasks/domaininfo.yml | 8 +- roles/init/tasks/mgmtuser.yml | 18 +++- roles/nethcfg/tasks/domain_groups.yml | 18 ++-- roles/nethcfg/tasks/neth_pkgs.yml | 2 +- roles/nethcfg/tasks/reconfig_nic.yml | 10 +-- roles/nethcfg/tasks/reconfig_srv.yml | 88 +++++++++---------- roles/npm/tasks/npm.yml | 2 +- roles/preseed/tasks/firefoxcert.yml | 8 +- roles/preseed/tasks/preseed.yml | 16 ++-- roles/pxe/tasks/pxe.yml | 32 +++---- roles/setup/handlers/main.yml | 4 +- roles/setup/tasks/ansible.yml | 6 +- roles/setup/tasks/centos_pkgs.yml | 14 +-- roles/setup/tasks/main.yml | 2 +- roles/setup/tasks/pvtrepo.yml | 4 +- roles/ubuntu-mirror/tasks/local-mirror.yml | 26 ++++-- roles/ubuntu-mirror/tasks/main.yml | 4 +- vagrant/roles/rename-nic/tasks/rename-nic.yml | 16 ++-- vagrant/roles/selinux/tasks/main.yml | 2 +- 23 files changed, 184 insertions(+), 162 deletions(-) diff --git a/roles/ansible-pull/tasks/ansible-pull.yml b/roles/ansible-pull/tasks/ansible-pull.yml index 0e08f9f..6dde5ce 100644 --- a/roles/ansible-pull/tasks/ansible-pull.yml +++ b/roles/ansible-pull/tasks/ansible-pull.yml @@ -1,7 +1,7 @@ --- - name: Creazione directory per ansible-pull file: path=/var/lib/nethserver/ibay/ks/ansible-pull state=directory - sudo: yes + become: yes - name: Template template: src={{ item }} dest=/var/lib/nethserver/ibay/ks/ansible-pull/{{ item }} @@ -10,8 +10,8 @@ - ansible-pull.sh - getvaultpass.py - crontab - sudo: yes + become: yes - name: Logrotate copy: src=logrotate dest=/var/lib/nethserver/ibay/ks/ansible-pull/logrotate - sudo: yes + become: yes diff --git a/roles/developuser/tasks/developuser.yml b/roles/developuser/tasks/developuser.yml index 9974d07..51834b3 100644 --- a/roles/developuser/tasks/developuser.yml +++ b/roles/developuser/tasks/developuser.yml @@ -6,7 +6,7 @@ - rpmdevtools - yum-utils - rpmlint - sudo: yes + become: yes - name: Aggiungo utente per compilazione pacchetti RPM user: @@ -14,16 +14,16 @@ password: $6$rounds=100000$neTGJ5N7Nu5ogCTX$VmVgS9HRZcdczjiNNdQcZzFVQI/3AFwu6MNFOKxGhBRY4VcBOo6GTxhXr0K/jYVFTygjHWsr.teM6RmBzSnz.0 shell: /bin/bash state: present - sudo: yes + become: yes - name: Copia della chiave pubblica authorized_key: user: makepkg key: "{{ lookup('file', '/Users/syntaxerrormmm/.ssh/id_rsa.pub') }}" state: present - sudo: yes + become: yes - name: Creazione directory per il build di RPM shell: rpmdev-setuptree - sudo: yes - sudo_user: makepkg + become: yes + become_user: makepkg diff --git a/roles/doraemon/tasks/doraemon.yml b/roles/doraemon/tasks/doraemon.yml index 03839b0..d4054f2 100644 --- a/roles/doraemon/tasks/doraemon.yml +++ b/roles/doraemon/tasks/doraemon.yml @@ -8,8 +8,8 @@ yum: pkg: doraemon state: latest - sudo: yes + become: yes - name: Verifico avvio di doraemon service: name=doraemon state=restarted - sudo: yes + become: yes diff --git a/roles/git-daemon/tasks/git-daemon.yml b/roles/git-daemon/tasks/git-daemon.yml index fc05dab..bcd2d1b 100644 --- a/roles/git-daemon/tasks/git-daemon.yml +++ b/roles/git-daemon/tasks/git-daemon.yml @@ -3,14 +3,14 @@ - name: Installo git-daemon yum: pkg=git-daemon state=present - sudo: yes + become: yes - name: Creazione gruppo git group: name: git system: yes state: present - sudo: yes + become: yes - name: Creazione utente git-daemon user: @@ -19,28 +19,28 @@ group: git home: /var/lib/git-daemon state: present - sudo: yes + become: yes - name: Creo directory repositories file: path: /var/lib/git-daemon/repositories state: directory - sudo: yes - sudo_user: git-daemon + become: yes + become_user: git-daemon - name: Verifica presenza repo shell: test -d /var/lib/git-daemon/repositories/client-pull-installation.git register: chk_clientpullinstall_repo changed_when: chk_clientpullinstall_repo.rc != 0 ignore_errors: yes - sudo: yes + become: yes tags: - git-daemon-update - name: Aggiorno il repo se già esistente shell: pushd /var/lib/git-daemon/repositories/client-pull-installation.git; git fetch -p origin; popd - sudo: yes - sudo_user: git-daemon + become: yes + become_user: git-daemon when: chk_clientpullinstall_repo|success tags: - git-daemon-update @@ -49,16 +49,16 @@ # il parametro --mirror - name: Clono il repository client-pull-installation shell: git clone --mirror https://github.com/bglug-it/client-pull-installation.git /var/lib/git-daemon/repositories/client-pull-installation.git - sudo: yes - sudo_user: git-daemon + become: yes + become_user: git-daemon when: chk_clientpullinstall_repo|changed - name: Rendo il repository esportabile file: path: /var/lib/git-daemon/repositories/client-pull-installation.git/git-daemon-export-ok state: touch - sudo: yes - sudo_user: git-daemon + become: yes + become_user: git-daemon tags: - git-daemon-update @@ -69,7 +69,7 @@ mode: 0644 owner: root group: root - sudo: yes + become: yes - name: Installo l'init copy: @@ -78,22 +78,22 @@ mode: 0755 owner: root group: root - sudo: yes + become: yes - name: Configuro l'avvio di git-daemon shell: /sbin/chkconfig --add git-daemon - sudo: yes + become: yes - name: Verifica aggiunta servizio shell: /sbin/e-smith/db configuration show git-daemon - sudo: yes + become: yes register: chk_gitdaemon_srv changed_when: chk_gitdaemon_srv.rc != 0 ignore_errors: yes - name: Aggiungo servizio a gestione NethServer shell: /sbin/e-smith/db configuration set git-daemon service status enabled TCPPort 9418 access private - sudo: yes + become: yes when: chk_gitdaemon_srv|changed - name: Creazione directory defaults per NethServer @@ -101,7 +101,7 @@ path: /etc/e-smith/db/configuration/defaults/git-daemon recurse: yes state: directory - sudo: yes + become: yes when: chk_gitdaemon_srv|changed - name: Creazione tipo default per NethServer @@ -111,7 +111,7 @@ line: "service" create: yes state: present - sudo: yes + become: yes when: chk_gitdaemon_srv|changed - name: Creazione stato default per NethServer @@ -121,20 +121,20 @@ line: "enabled" create: yes state: present - sudo: yes + become: yes when: chk_gitdaemon_srv|changed - name: Aggiunta servizio shell: /sbin/e-smith/signal-event runlevel-adjust - sudo: yes + become: yes when: chk_gitdaemon_srv|changed - name: Aggiunta servizio di rete e cambio firewall shell: /sbin/e-smith/signal-event firewall-adjust - sudo: yes + become: yes when: chk_gitdaemon_srv|changed - name: Avvio servizio shell: service git-daemon start - sudo: yes + become: yes when: chk_gitdaemon_srv|changed diff --git a/roles/init/tasks/domaininfo.yml b/roles/init/tasks/domaininfo.yml index 64f6b20..b4f3812 100644 --- a/roles/init/tasks/domaininfo.yml +++ b/roles/init/tasks/domaininfo.yml @@ -2,21 +2,21 @@ # Copia le configurazioni per il dominio in locale sul server. - name: Copia le configurazioni di dominio. copy: src=../../../domain.yml dest=/etc/domain.yml force=yes - sudo: yes + become: yes - name: Creo la cartella per le configurazioni di Ansible file: path=/etc/ansible/facts.d state=directory owner=root mode=0755 - sudo: yes + become: yes - name: Installo PyYAML, necessario per i facts yum: name: PyYAML state: present - sudo: yes + become: 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 + become: yes - name: Rileggo i fatti per essere sicuri che vengano utilizzati setup: filter=ansible_local diff --git a/roles/init/tasks/mgmtuser.yml b/roles/init/tasks/mgmtuser.yml index 88c5e1d..0e5e44d 100644 --- a/roles/init/tasks/mgmtuser.yml +++ b/roles/init/tasks/mgmtuser.yml @@ -1,9 +1,21 @@ --- - name: Creazione account di gestione Ansible - user: name=amgmt comment="Ansible Management User" group=wheel state=present password=$6$rounds=100000$XvHuMoXtpCksx379$nhlfUn38.oBB7JrDrtwfUisw8T0Bg5InzFq1fw31mcEmGZ2AYFkFK2zC2g04lSfw.kpdSgqH3Dl5q9r1fY6.k. + user: + name: amgmt + comment: "Ansible Management User" + group: wheel + state: present + password: $6$rounds=100000$XvHuMoXtpCksx379$nhlfUn38.oBB7JrDrtwfUisw8T0Bg5InzFq1fw31mcEmGZ2AYFkFK2zC2g04lSfw.kpdSgqH3Dl5q9r1fY6.k. - name: Concessione diritti all'utente di gestione Ansible - template: src=sudoers.d dest=/etc/sudoers.d/amgmt mode="u=r,g=r" validate="visudo -cf %s" + template: + src: sudoers.d + dest: /etc/sudoers.d/amgmt + mode: "u=r,g=r" + validate: "visudo -cf %s" - name: Installazione chiave privata PC locale - authorized_key: user=amgmt key="{{ lookup('file', admin_sshkey) }}" state=present + authorized_key: + user: amgmt + key: "{{ lookup('file', admin_sshkey) }}" + state: present diff --git a/roles/nethcfg/tasks/domain_groups.yml b/roles/nethcfg/tasks/domain_groups.yml index 53fe742..1c2bd6c 100644 --- a/roles/nethcfg/tasks/domain_groups.yml +++ b/roles/nethcfg/tasks/domain_groups.yml @@ -2,48 +2,48 @@ - name: Verifico la presenza del gruppo Domain Users shell: /sbin/e-smith/db accounts show domusers register: check_domusers - sudo: yes + become: yes ignore_errors: true - name: Creazione gruppo Domain Users shell: /sbin/e-smith/db accounts set domusers group Description "Domain Users" Members admin Removable no - sudo: yes + become: yes when: check_domusers|failed - name: Configurazione nuovo gruppo Domain Users shell: /sbin/e-smith/signal-event group-create domusers - sudo: yes + become: yes when: check_domusers|failed - name: Verifico la presenza del gruppo Domain Operators shell: /sbin/e-smith/db accounts show domopers register: check_domopers - sudo: yes + become: yes ignore_errors: true - name: Creazione gruppo Domain Operators shell: /sbin/e-smith/db accounts set domopers group Description "Domain Operators" Removable no - sudo: yes + become: yes when: check_domopers|failed - name: Configurazione nuovo gruppo Domain Operators shell: /sbin/e-smith/signal-event group-create domopers - sudo: yes + become: yes when: check_domopers|failed - name: Verifico la presenza del gruppo Docenti shell: /sbin/e-smith/db accounts show docenti register: check_docenti - sudo: yes + become: yes ignore_errors: true - name: Creazione gruppo Docenti shell: /sbin/e-smith/db accounts set docenti group Description "Docenti" Removable no - sudo: yes + become: yes when: check_docenti|failed - name: Configurazione nuovo gruppo Docenti shell: /sbin/e-smith/signal-event group-create docenti - sudo: yes + become: yes when: check_docenti|failed diff --git a/roles/nethcfg/tasks/neth_pkgs.yml b/roles/nethcfg/tasks/neth_pkgs.yml index 5ad6d60..441e27f 100644 --- a/roles/nethcfg/tasks/neth_pkgs.yml +++ b/roles/nethcfg/tasks/neth_pkgs.yml @@ -2,5 +2,5 @@ - name: Installazione pacchetti neth yum: name="{{ item }}" state=present - sudo: yes + become: yes with_items: neth_pkgs diff --git a/roles/nethcfg/tasks/reconfig_nic.yml b/roles/nethcfg/tasks/reconfig_nic.yml index 68be253..2f57fdc 100644 --- a/roles/nethcfg/tasks/reconfig_nic.yml +++ b/roles/nethcfg/tasks/reconfig_nic.yml @@ -1,19 +1,19 @@ - name: Configurazione scheda di rete esterna shell: /sbin/e-smith/db networks setprop {{ extnic }} role red bootproto dhcp - sudo: yes + become: yes - name: Configurazione scheda di rete interna shell: /sbin/e-smith/db networks setprop {{ intnic }} role green ipaddr {{ ansible_local.domain.serverip }} netmask {{ ansible_local.domain.servernetmask }} - sudo: yes + become: yes - name: Attivo configurazioni di rete shell: /sbin/e-smith/signal-event interface-update - sudo: yes + become: yes - name: Configurazione rete trusted shell: /sbin/e-smith/db networks set {{ ansible_local.domain.servernet }} network Description "Local LAN" Mask {{ ansible_local.domain.servernetmask }} - sudo: yes + become: yes - name: Modifico configurazioni shell: /sbin/e-smith/signal-event trusted-networks-modify - sudo: yes + become: yes diff --git a/roles/nethcfg/tasks/reconfig_srv.yml b/roles/nethcfg/tasks/reconfig_srv.yml index d25b65f..0ba28bd 100644 --- a/roles/nethcfg/tasks/reconfig_srv.yml +++ b/roles/nethcfg/tasks/reconfig_srv.yml @@ -4,95 +4,95 @@ register: check_org changed_when: "'City={{ ansible_local.domain.org_city }}' not in check_org.stdout" ignore_errors: yes - sudo: yes + become: yes - name: Configurazione organizzazione 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 + become: yes when: check_org|changed - name: Configurazione nome server shell: /sbin/e-smith/db configuration set SystemName {{ ansible_local.domain.server }} - sudo: yes + become: yes register: chg_hostname when: "'{{ ansible_hostname }}' != '{{ ansible_local.domain.server }}'" - name: Configurazione nome dominio shell: /sbin/e-smith/db configuration set DomainName {{ ansible_local.domain.domainfull }} - sudo: yes + become: yes register: chg_domainname when: "'{{ ansible_domain }}' != '{{ ansible_local.domain.domainfull }}'" - name: Attivazione cambiamenti hostname shell: /sbin/e-smith/signal-event hostname-modify - sudo: yes + become: yes when: chg_hostname|changed or chg_domainname|changed - name: Verifica robustezza password shell: /sbin/e-smith/db configuration printprop passwordstrength Users register: chk_passstr changed_when: "'Users=none' not in chk_passstr.stdout" - sudo: yes + become: yes ignore_errors: true - name: Configurazione forza password shell: /sbin/e-smith/db configuration setprop passwordstrength PassExpires no Users none Admin strong MaxPassAge 180 MinPassAge 0 PassExpires no PassWarning 7 - sudo: yes + become: yes when: chk_passstr|changed - name: Attivo configurazione policy password shell: /sbin/e-smith/signal-event password-policy-update - sudo: yes + become: yes when: chk_passstr|changed - name: Verifica configurazione DHCP shell: /sbin/e-smith/db dhcp getprop {{ intnic }} DhcpRangeStart - sudo: yes + become: yes ignore_errors: true register: chk_dhcp - name: Configurazione servizio DHCP shell: /sbin/e-smith/db dhcp set {{ intnic }} range DhcpRangeStart {{ ansible_local.domain.dhcprange_start }} DhcpRangeEnd {{ ansible_local.domain.dhcprange_end }} status enabled - sudo: yes + become: yes when: chk_dhcp|failed - name: Attivazione configurazione DHCP shell: /sbin/e-smith/signal-event nethserver-dnsmasq-save - sudo: yes + become: yes when: chk_dhcp|failed - name: Verifica configurazione DNS shell: /sbin/e-smith/db configuration printprop dns NameServers - sudo: yes + become: yes register: chk_dns changed_when: "'NameServers={{ ansible_local.domain.extdnsserver1 }},{{ ansible_local.domain.extdnsserver2 }}' not in chk_dns.stdout" ignore_errors: yes - name: Configurazione servizio DNS shell: /sbin/e-smith/db configuration setprop dns role resolver NameServers "{{ ansible_local.domain.extdnsserver1 }},{{ ansible_local.domain.extdnsserver2 }}" - sudo: yes + become: yes when: chk_dns|changed - name: Attivo configurazione DNS shell: /sbin/e-smith/signal-event nethserver-dnsmasq-save when: chk_dns|changed - sudo: yes + become: yes - name: Verifica configurazione NTP shell: /sbin/e-smith/db configuration printprop ntpd NTPServer - sudo: yes + become: yes register: chk_ntp changed_when: "'NTPServer=ntp1.inrim.it' not in chk_ntp.stdout" ignore_errors: true - name: Configuro NTP shell: /sbin/e-smith/db configuration setprop ntpd NTPServer ntp1.inrim.it status enabled - sudo: yes + become: yes when: chk_ntp|changed - name: Attivazione NTP shell: /sbin/e-smith/signal-event nethserver-ntp-update - sudo: yes + become: yes when: chk_ntp|changed - name: Utilizzo unix extensions nei template per ibay @@ -100,23 +100,23 @@ dest: /etc/e-smith/templates/etc/samba/smb.conf/10global regexp: '^unix extensions = no$' replace: 'unix extensions = yes' - sudo: yes + become: yes - name: Verifica configurazione SMB shell: /sbin/e-smith/db configuration printprop smb RoamingProfiles - sudo: yes + become: yes register: chk_smb changed_when: "'RoamingProfiles=yes' not in chk_smb.stdout" ignore_errors: true - name: Configurazione SMB shell: /sbin/e-smith/db configuration setprop smb RoamingProfiles yes ServerRole PDC Workgroup "{{ ansible_local.domain.domainshort }}" status enabled - sudo: yes + become: yes when: chk_smb|changed - name: Attivo configurazione SMB shell: /sbin/e-smith/signal-event nethserver-samba-save - sudo: yes + become: yes when: chk_smb|changed - name: Abilito il ricaricamento dei servizi smb su ibay-create @@ -125,17 +125,17 @@ - /etc/e-smith/events/ibay-delete/services2adjust - /etc/e-smith/events/ibay-create/services2adjust - /etc/e-smith/events/ibay-modify/services2adjust - sudo: yes + become: yes - name: Verifica creazione share condiviso shell: /sbin/e-smith/db accounts show shared - sudo: yes + become: yes ignore_errors: true register: chk_shared - name: Copying default templates for new template type shell: cp -r /etc/e-smith/templates/etc/samba/smb.conf/ibay-default /etc/e-smith/templates/etc/samba/smb.conf/ibay-shared - sudo: yes + become: yes when: force_ibay_shared|bool or chk_shared|failed - name: Configuring ibay-shared template structure (directory mask) @@ -144,7 +144,7 @@ line: 'directory mask = 0775' insertafter: '^create mask' state: present - sudo: yes + become: yes when: force_ibay_shared|bool or chk_shared|failed - name: Configuring force create mode @@ -153,7 +153,7 @@ line: 'force create mode = 0664' insertafter: '^directory mask' state: present - sudo: yes + become: yes when: force_ibay_shared|bool or chk_shared|failed - name: Configuring force directory mode @@ -162,88 +162,88 @@ line: 'force directory mode = 0775' insertafter: '^force create mode' state: present - sudo: yes + become: yes when: force_ibay_shared|bool or chk_shared|failed - name: Configurazione share Condiviso shell: /sbin/e-smith/db accounts set shared ibay AclRead domusers,domadmins AclWrite domusers,domadmins Description "Cartella condivisa" GroupAccess rw HttpStatus disabled OtherAccess r OwningGroup locals SmbAuditStatus enabled SmbGuestAccessType none SmbRecycleBinStatus enabled SmbRecycleBinVersionsStatus enabled SmbStatus enabled - sudo: yes + become: yes when: chk_shared|failed - name: Attivazione share condiviso shell: /sbin/e-smith/signal-event ibay-create shared - sudo: yes + become: yes when: chk_shared|failed - name: Changing ibay profile for shared shell: /sbin/e-smith/db accounts setprop shared SmbProfileType shared - sudo: yes + become: yes when: force_ibay_shared|bool or chk_shared|failed - name: Forcing regeneration of smb.conf shell: /sbin/e-smith/signal-event nethserver-samba-update - sudo: yes + become: yes when: force_ibay_shared|bool or chk_shared|failed - name: Verifica configurazione squid shell: /sbin/e-smith/db configuration printprop squid GreenMode - sudo: yes + become: yes ignore_errors: yes register: chk_squid changed_when: "'GreenMode=transparent_ssl' not in chk_squid.stdout" - name: Configurazione squid shell: /sbin/e-smith/db configuration setprop squid BlueMode transparent_ssl GreenMode transparent_ssl PortBlock enabled status enabled DiskCache enabled DiskCacheSize 500 - sudo: yes + become: yes when: chk_squid|changed - name: Attivazione configurazione squid shell: /sbin/e-smith/signal-event nethserver-squid-update - sudo: yes + become: yes when: chk_squid|changed - name: Verifica configurazione squidguard shell: /sbin/e-smith/db configuration printprop squidguard Lists - sudo: yes + become: yes ignore_errors: true register: chk_squidguard changed_when: "'Lists=shalla' not in chk_squidguard.stdout" - name: Configurazione squidguard shell: /sbin/e-smith/db configuration setprop squidguard Expressions enabled Lists shalla status enabled - sudo: yes + become: yes when: chk_squidguard|changed - name: Scarico liste di filtraggio shell: /sbin/e-smith/signal-event nethserver-squidguard-downloadlists - sudo: yes + become: yes when: chk_squidguard|changed - name: Attivazione squidguard shell: /sbin/e-smith/signal-event nethserver-squidguard-update - sudo: yes + become: yes when: chk_squidguard|changed - name: Verifica configurazione squidclamav shell: /sbin/e-smith/db configuration printprop squidclamav status - sudo: yes + become: yes ignore_errors: true register: chk_squidclamav changed_when: "'status=enabled' not in chk_squidclamav.stdout" - name: Configurazione squidclamav shell: /sbin/e-smith/db configuration setprop squidclamav status enabled - sudo: yes + become: yes when: chk_squidclamav|changed - name: Attivazione squidclamav shell: /sbin/e-smith/signal-event nethserver-squidclamav-update - sudo: yes + become: yes when: chk_squidclamav|changed - name: Verifica completamento configurazione per certificato shell: /sbin/e-smith/db configuration printprop pki CommonName - sudo: yes + become: yes ignore_errors: true register: chk_crt changed_when: "'CommonName={{ ansible_local.domain.serverfqdn }}' not in chk_crt.stdout" @@ -251,12 +251,12 @@ - name: Completo la configurazione per produzione certificato shell: /sbin/e-smith/db configuration setprop pki CertificateDuration 3650 CommonName {{ ansible_local.domain.serverfqdn }} CountryCode {{ ansible_local.domain.org_countrycode }} EmailAddress {{ ansible_local.domain.org_email }} Locality "{{ ansible_local.domain.org_city }}" Organization "{{ ansible_local.domain.org_company }}" - sudo: yes + become: yes tags: regen-ca when: chk_crt|changed or force_regen_ca|bool - name: Rigenero il certificato con le informazioni inserite shell: /sbin/e-smith/signal-event certificate-update - sudo: yes + become: yes when: chk_crt|changed or force_regen_ca|bool tags: regen-ca diff --git a/roles/npm/tasks/npm.yml b/roles/npm/tasks/npm.yml index 961fd7f..fa143e3 100644 --- a/roles/npm/tasks/npm.yml +++ b/roles/npm/tasks/npm.yml @@ -5,4 +5,4 @@ yum: pkg: nethserver-networkpackagemanager state: latest - sudo: yes + become: yes diff --git a/roles/preseed/tasks/firefoxcert.yml b/roles/preseed/tasks/firefoxcert.yml index 596e969..dd2ab49 100644 --- a/roles/preseed/tasks/firefoxcert.yml +++ b/roles/preseed/tasks/firefoxcert.yml @@ -13,7 +13,7 @@ state: directory owner: root mode: 0755 - sudo: yes + become: yes - name: 'Utilizzo cert8.db precedentemente fornito (pulito da FF appena aperto)' copy: @@ -21,15 +21,15 @@ dest: /var/lib/nethserver/ibay/ks/server-ca/cert8.db owner: root mode: 0644 - sudo: yes + become: yes - name: Integro la CA nel db shell: certutil -A -n "{{ ansible_local.domain.domainfull }}" -t "TCu,Cuw,Tuw" -i /tmp/ca.crt -d /var/lib/nethserver/ibay/ks/server-ca - sudo: yes + become: yes - name: Pulizia shell: rm -f {{ item }} - sudo: yes + become: yes with_items: - /tmp/ca.crt - /var/lib/nethserver/ibay/ks/server-ca/key3.db diff --git a/roles/preseed/tasks/preseed.yml b/roles/preseed/tasks/preseed.yml index 474b633..20f4b58 100644 --- a/roles/preseed/tasks/preseed.yml +++ b/roles/preseed/tasks/preseed.yml @@ -4,34 +4,34 @@ register: chk_ks_created changed_when: chk_ks_created.rc != 0 ignore_errors: yes - sudo: yes + become: yes - name: Configurazione web preseed shell: /sbin/e-smith/db accounts set ks ibay Description "Preseed 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 + become: yes - name: Attivazione web preseed shell: /sbin/e-smith/signal-event ibay-create ks when: chk_ks_created|failed - sudo: yes + become: yes - name: Verifica presenza directory mirror file: path=/var/spool/apt-mirror/mirror state=directory register: chk_mirror_dir ignore_errors: yes - sudo: yes + become: yes - name: Collegamento directory mirror file: path=/var/lib/nethserver/ibay/ks/mirror src=/var/spool/apt-mirror/mirror state=link - sudo: yes + become: yes when: chk_mirror_dir|success - name: Creazione directory preseed file: path: "/var/lib/nethserver/ibay/ks/preseed" state: directory - sudo: yes + become: yes - name: Copia profili preseed template: @@ -41,7 +41,7 @@ - edubuntu.seed - client-trusty.seed - docenti-trusty.seed - sudo: yes + become: yes - name: Copia script post-installazione template: @@ -52,4 +52,4 @@ - postseed-docenti.sh - pulseaudio-perms.sh - checksum.fact - sudo: yes + become: yes diff --git a/roles/pxe/tasks/pxe.yml b/roles/pxe/tasks/pxe.yml index 74c33bf..8d12856 100644 --- a/roles/pxe/tasks/pxe.yml +++ b/roles/pxe/tasks/pxe.yml @@ -6,17 +6,17 @@ register: chk_tftp_enabled changed_when: "'pxelinux.0' not in chk_tftp_enabled.stdout" ignore_errors: yes - sudo: yes + become: 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 + become: yes - name: Attivo tftp shell: /sbin/e-smith/signal-event nethserver-dnsmasq-save when: chk_tftp_enabled|changed - sudo: yes + become: yes - name: Creo directory necessarie file: path={{ item }} state=directory @@ -25,72 +25,72 @@ - /var/lib/tftpboot/ubuntu/14.04/i386 - /var/lib/tftpboot/ubuntu/14.04/amd64 - /var/lib/tftpboot/utils/memtest86 - sudo: yes + become: yes - name: pxelinux.0 get_url: url: http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/pxelinux.0 dest: /var/lib/tftpboot/pxelinux.0 - sudo: yes + become: yes - name: pxelinux.cfg/default template: src=pxelinux.cfg/default dest=/var/lib/tftpboot/pxelinux.cfg/default - sudo: yes + become: yes - name: bglug.png copy: src=bglug.png dest=/var/lib/tftpboot/utils/bglug.png - sudo: yes + become: yes - name: vesamenu.c32 get_url: url: http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/ubuntu-installer/i386/boot-screens/vesamenu.c32 dest: /var/lib/tftpboot/utils/vesamenu.c32 - sudo: yes + become: yes - name: chain.c32 get_url: url: "http://bglug.sys42.eu/chain.c32" dest: /var/lib/tftpboot/utils/chain.c32 - sudo: yes + become: yes - name: linux i386 get_url: url: http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/ubuntu-installer/i386/linux dest: /var/lib/tftpboot/ubuntu/14.04/i386/linux - sudo: yes + become: yes - name: initrd.gz i386 get_url: url: http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/ubuntu-installer/i386/initrd.gz dest: /var/lib/tftpboot/ubuntu/14.04/i386/initrd.gz - sudo: yes + become: yes - name: linux amd64 get_url: url: http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux dest: /var/lib/tftpboot/ubuntu/14.04/amd64/linux - sudo: yes + become: yes - name: initrd.gz amd64 get_url: url: http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz dest: /var/lib/tftpboot/ubuntu/14.04/amd64/initrd.gz - sudo: yes + become: yes - name: memdisk get_url: url: http://sys42.eu/pxe-bootimg/memdisk dest: /var/lib/tftpboot/utils/memdisk - sudo: yes + become: yes - name: memtest86 get_url: url: http://sys42.eu/pxe-bootimg/memtest86/vmlinuz dest: /var/lib/tftpboot/utils/memtest86/vmlinuz - sudo: yes + become: yes - name: hdt get_url: url: http://sys42.eu/pxe-bootimg/hdt.img dest: /var/lib/tftpboot/utils/hdt.img - sudo: yes + become: yes diff --git a/roles/setup/handlers/main.yml b/roles/setup/handlers/main.yml index 2eb9298..22fa16f 100644 --- a/roles/setup/handlers/main.yml +++ b/roles/setup/handlers/main.yml @@ -1,8 +1,8 @@ --- - name: ntp save shell: /sbin/e-smith/signal-event nethserver-ntp-save - sudo: yes + become: yes - name: password-policy-update shell: /sbin/e-smith/signal-event password-policy-update - sudo: yes + become: yes diff --git a/roles/setup/tasks/ansible.yml b/roles/setup/tasks/ansible.yml index 82b659f..955d881 100644 --- a/roles/setup/tasks/ansible.yml +++ b/roles/setup/tasks/ansible.yml @@ -2,19 +2,19 @@ - name: Verifica installazione git yum: name=git state=present - sudo: yes + become: yes tags: git - name: Verifica installazione ansible yum: name=ansible state=present - sudo: yes + become: yes tags: ansible - name: Installazione python-argparse shell: name: "ftp://fr2.rpmfind.net/linux/centos/6.7/extras/i386/Packages/python-argparse-1.2.1-2.el6.centos.noarch.rpm" state: present - sudo: yes + become: yes tags: ansible #- name: Download della gestione client con ansible diff --git a/roles/setup/tasks/centos_pkgs.yml b/roles/setup/tasks/centos_pkgs.yml index e282ac0..eb27966 100644 --- a/roles/setup/tasks/centos_pkgs.yml +++ b/roles/setup/tasks/centos_pkgs.yml @@ -8,7 +8,7 @@ - name: Installo epel-release yum: name=epel-release state=present - sudo: yes + become: yes when: check_epel|failed register: epel_installed ignore_errors: yes @@ -17,31 +17,31 @@ yum: name: "http://dl.fedoraproject.org/pub/epel/6/{{ ansible_architecture }}/epel-release-6-8.noarch.rpm" state: present - sudo: yes + become: yes when: epel_installed|failed register: rpm_epel_installed - name: Abilito il repo EPEL shell: yum-config-manager --enable epel - sudo: yes + become: yes when: epel_installed|changed or epel_installed|success or rpm_epel_installed|changed changed_when: "'[epel]' in epel_enabled.stdout and epel_enabled.rc == 0" register: epel_enabled - name: Pulizia e ricaricam. repo shell: yum clean all && yum repolist - sudo: yes + become: yes when: epel_enabled|changed tags: repo - name: Aggiorno il sistema yum: name=* state=latest - sudo: yes + become: yes tags: upgrade - name: Installo pacchetti addizionali yum: name={{ item }} state=present - sudo: yes + become: yes with_items: addin_pkgs tags: pkg @@ -50,4 +50,4 @@ yum: name: "http://rpm.mag-sol.com/Centos/6/{{ ansible_architecture }}/perl-Authen-SASL-2.16-1.el6.noarch.rpm" state: present - sudo: yes + become: yes diff --git a/roles/setup/tasks/main.yml b/roles/setup/tasks/main.yml index 79ac28e..1b2a2fa 100644 --- a/roles/setup/tasks/main.yml +++ b/roles/setup/tasks/main.yml @@ -4,7 +4,7 @@ tags: ssh - include: lock-nethrelease.yml - sudo: yes + become: yes tags: lock-nethrelease - include: centos_pkgs.yml diff --git a/roles/setup/tasks/pvtrepo.yml b/roles/setup/tasks/pvtrepo.yml index 5e7aa0e..a2cf4d0 100644 --- a/roles/setup/tasks/pvtrepo.yml +++ b/roles/setup/tasks/pvtrepo.yml @@ -3,8 +3,8 @@ copy: src: sys42.repo dest: /etc/yum.repos.d/sys42.repo - sudo: yes + become: yes - name: Ricalcolo repository disponibili shell: yum repolist - sudo: yes + become: yes diff --git a/roles/ubuntu-mirror/tasks/local-mirror.yml b/roles/ubuntu-mirror/tasks/local-mirror.yml index 0af1560..f31f490 100644 --- a/roles/ubuntu-mirror/tasks/local-mirror.yml +++ b/roles/ubuntu-mirror/tasks/local-mirror.yml @@ -2,17 +2,27 @@ # Configurazione del server come repo - name: Installazione apt-mirror - yum: pkg=apt-mirror state=present - sudo: yes + yum: + pkg: apt-mirror + state: present + become: yes - name: Installazione configurazione apt-mirror - copy: src=apt-mirror.list dest=/etc/apt-mirror.list - sudo: yes + copy: + src: apt-mirror.list + dest: /etc/apt-mirror.list + become: yes - name: Installazione cron per sincronizzazione notturna - copy: src=apt-mirror-cron dest=/etc/cron.daily/apt-mirror mode=0755 - sudo: yes + copy: + src: apt-mirror-cron + dest: /etc/cron.daily/apt-mirror + mode: 0755 + become: yes - name: Installazione logrotate per sincronizzazione notturna - copy: src=apt-mirror-logrotate dest=/etc/logrotate.d/apt-mirror mode=0644 - sudo: yes + copy: + src: apt-mirror-logrotate + dest: /etc/logrotate.d/apt-mirror + mode: 0644 + become: yes diff --git a/roles/ubuntu-mirror/tasks/main.yml b/roles/ubuntu-mirror/tasks/main.yml index 6abeef2..ab5c4c4 100644 --- a/roles/ubuntu-mirror/tasks/main.yml +++ b/roles/ubuntu-mirror/tasks/main.yml @@ -13,14 +13,14 @@ - include: nfs-mirror.yml when: ansible_local.domain.mirror_mode == 'nfs' - sudo: yes + become: yes tags: - mirror - nfs-mirror - include: remote-mirror.yml when: ansible_local.domain.mirror_mode == 'remote' - sudo: yes + become: yes tags: - mirror - remote-mirror diff --git a/vagrant/roles/rename-nic/tasks/rename-nic.yml b/vagrant/roles/rename-nic/tasks/rename-nic.yml index e0095ac..c9a7039 100644 --- a/vagrant/roles/rename-nic/tasks/rename-nic.yml +++ b/vagrant/roles/rename-nic/tasks/rename-nic.yml @@ -5,36 +5,36 @@ dest: /etc/udev/rules.d/70-persistent-net.rules regexp: 'eth0' replace: '{{ extnic }}' - sudo: yes + become: yes - name: Creo interfaccia esterna in NethServer shell: /sbin/e-smith/db networks set {{ extnic }} ethernet bootproto dhcp device {{ extnic }} hwaddr {{ ansible_eth0.macaddress }} onboot yes peerdns yes role red - sudo: yes + become: yes - name: Pulizia vecchia interfaccia esterna shell: /sbin/e-smith/db networks delete eth0 - sudo: yes + become: yes - name: Rinomino interfaccia interna replace: dest: /etc/udev/rules.d/70-persistent-net.rules regexp: 'eth1' replace: '{{ intnic }}' - sudo: yes + become: yes - name: Creo interfaccia interna in NethServer shell: /sbin/e-smith/db networks set {{ intnic }} ethernet bootproto none device {{ intnic }} hwaddr {{ ansible_eth1.macaddress }} ipaddr 192.168.1.1 netmask 255.255.255.0 onboot yes role green - sudo: yes + become: yes - name: Pulizia vecchia interfaccia interna shell: /sbin/e-smith/db networks delete eth1 - sudo: yes + become: yes # Forzo il processo a tornare zero, altrimenti non va. - name: Ricreo le interfacce shell: udevadm control --reload-rules && udevadm trigger --attr-match=subsystem=net - sudo: yes + become: yes - name: Segnalo il cambiamento a livello di interfacce shell: /sbin/e-smith/signal-event interface-update - sudo: yes + become: yes diff --git a/vagrant/roles/selinux/tasks/main.yml b/vagrant/roles/selinux/tasks/main.yml index e03940d..0878b8e 100644 --- a/vagrant/roles/selinux/tasks/main.yml +++ b/vagrant/roles/selinux/tasks/main.yml @@ -4,4 +4,4 @@ yum: name: libselinux-python state: present - sudo: yes + become: yes