浏览代码

Switch when_* conditions to when

Emmanuel Bouthenot 11 年之前
父节点
当前提交
6ff6e76f2a

+ 1 - 1
roles/common/tasks/base.yml

@@ -61,7 +61,7 @@
       - 10-disks.conf
   notify:
     - Refresh sysfs configuration
-  when_boolean: ${sysfs_disk_settings}
+  when: ${sysfs_disk_settings}
 
 - name: Install sudo configuration
   action: template src=sudo/local-admin.j2 dest=/etc/sudoers.d/local-admin owner=root group=root mode=0440

+ 2 - 2
roles/common/tasks/ovh.yml

@@ -4,7 +4,7 @@
       - 01-ovh-network.conf
   notify:
     - Apply kernel configuration (proc)
-  when_boolean: ${with_ovh}
+  when: ${with_ovh}
 
 - name: Install kernel configuration for OVH dedicated servers (sys)
   action: template src=kernel/sysfs.d/${item}.j2 dest=/etc/sysfs.d/${item} owner=root group=root mode=0644
@@ -12,4 +12,4 @@
       - 01-ovh-network.conf
   notify:
     - Refresh sysfs configuration
-  when_boolean: ${with_ovh}
+  when: ${with_ovh}

+ 8 - 8
roles/common/tasks/security.yml

@@ -1,20 +1,20 @@
 - name: Install auto upgrades package
   action: ${ansible_pkg_mgr} pkg=unattended-upgrades state=installed update_cache=yes
-  when_boolean: ${with_auto_upgrade}
+  when: ${with_auto_upgrade}
 
 - name: Configure auto upgrades
   action: template src=${item} dest=/etc/apt/apt.conf.d/20auto-upgrades owner=root group=root mode=0644
   first_available_file:
     - apt/auto-upgrades.${ansible_lsb.codename}.j2
     - apt/auto-upgrades.j2
-  when_boolean: ${with_auto_upgrade}
+  when: ${with_auto_upgrade}
 
 - name: Install logcheck packages
   action: ${ansible_pkg_mgr} pkg=${item} state=installed update_cache=yes
   with_items:
     - logcheck
     - logcheck-database
-  when_boolean: ${with_logcheck}
+  when: ${with_logcheck}
 
 - name: Install local configuration files for logcheck
   action: copy src=logcheck/${item}_local dest=/etc/logcheck/ignore.d.server/${item}_local owner=root group=root mode=0644
@@ -42,20 +42,20 @@
     - sshd
     - svn
     - sympa
-  when_boolean: ${with_logcheck}
+  when: ${with_logcheck}
 
 - name: Update logcheck cron job
   action: template src=cron/logcheck.j2 dest=/etc/cron.d/logcheck owner=root group=root mode=0644
-  when_boolean: ${with_logcheck}
+  when: ${with_logcheck}
 
 - name: Update rkhunter default/init parameters
   action: template src=rkhunter/default.j2 dest=/etc/default/rkhunter owner=root group=root mode=0644
-  when_boolean: ${with_rkhunter}
+  when: ${with_rkhunter}
 
 - name: Update rkhunter configuration
   action: template src=rkhunter/${ansible_lsb.codename}.conf.j2 dest=/etc/rkhunter.conf owner=root group=root mode=0644
-  when_boolean: ${with_rkhunter}
+  when: ${with_rkhunter}
 
 - name: Update chkrootkit configuration
   action: template src=chkrootkit/chkrootkit.conf.j2 dest=/etc/chkrootkit.conf owner=root group=root mode=0644
-  when_boolean: ${with_chkrootkit}
+  when: ${with_chkrootkit}

+ 4 - 4
roles/common/tasks/smartd.yml

@@ -1,6 +1,6 @@
 - name: Install smartmontools package
   action: ${ansible_pkg_mgr} pkg=smartmontools state=installed update_cache=yes
-  when_boolean: ${with_smartd}
+  when: ${with_smartd}
 
 - name: Install smartd configuration
   action: template dest=/etc/smartd.conf owner=root group=root mode=0644
@@ -9,14 +9,14 @@
     - smartd/smartd.conf.j2
   notify:
     - Restart smartmontools
-  when_boolean: ${with_smartd}
+  when: ${with_smartd}
 
 - name: Update smartmontools default/init parameters
   action: template src=smartd/default.j2 dest=/etc/default/smartmontools owner=root group=root mode=0644
   notify:
     - Restart smartmontools
-  when_boolean: ${with_smartd}
+  when: ${with_smartd}
 
 - name: Ensure smartmontools is running
   action: service name=smartmontools state=started
-  when_boolean: ${with_smartd}
+  when: ${with_smartd}

+ 3 - 3
roles/common/tasks/smtp.yml

@@ -1,15 +1,15 @@
 - name: Install postfix packages
   action: apt pkg=postfix state=installed update_cache=yes
-  when_boolean: ${with_postfix}
+  when: ${with_postfix}
 
 - name: Install mail aliases file
   action: template src=aliases.j2 dest=/etc/aliases owner=root group=root mode=0644
   notify:
     - Regenerate aliases cache
-  when_boolean: ${with_postfix} or ${with_mail_aliases}
+  when: ${with_postfix} or ${with_mail_aliases}
 
 - name: Install postfix main configuration
   action: template src=postfix/main.cf.j2 dest=/etc/postfix/main.cf owner=root group=root mode=0644
   notify:
     - Restart postfix
-  when_boolean: ${with_postfix}
+  when: ${with_postfix}

+ 3 - 3
roles/common/tasks/ssh.yml

@@ -3,14 +3,14 @@
   with_items:
     - openssh-server
     - openssh-client
-  when_boolean: ${with_ssh}
+  when: ${with_ssh}
 
 - name: Install sshd configuration
   action: template src=ssh/sshd_config.j2 dest=/etc/ssh/sshd_config owner=root group=root mode=0644
   notify:
     - Restart ssh
-  when_boolean: ${with_ssh}
+  when: ${with_ssh}
 
 - name: Ensure ssh is running
   action: service name=ssh state=started
-  when_boolean: ${with_ssh}
+  when: ${with_ssh}

+ 3 - 3
roles/dbserver/tasks/mysql.yml

@@ -3,12 +3,12 @@
   with_items:
     - mysql-server
     - automysqlbackup
-  when_boolean: ${with_mysql}
+  when: ${with_mysql}
 
 - name: Change mysql root default password
   action: raw if "SELECT VERSION();" | mysql -u root >/dev/null 2>&1 ; then echo "UPDATE mysql.user SET Password=PASSWORD('${mysql_root_password}') WHERE User IN ('', 'root'); FLUSH PRIVILEGES;" | mysql --defaults-file=/etc/mysql/debian.cnf ; fi
-  when_boolean: ${with_mysql}
+  when: ${with_mysql}
 
 - name: Ensure mysql-server is running
   action: service name=mysql state=started
-  when_boolean: ${with_mysql}
+  when: ${with_mysql}

+ 7 - 7
roles/monitoring/tasks/mon.yml

@@ -1,22 +1,22 @@
 - name: Install mon packages
   action: ${ansible_pkg_mgr} pkg=mon state=installed update_cache=yes
-  when_boolean: ${with_mon}
+  when: ${with_mon}
 
 - name: Create need directory for mon configuration
   action: file path=/etc/mon/mon.d state=directory owner=root group=root mode=0755
-  when_boolean: ${with_mon}
+  when: ${with_mon}
 
 - name: Install mon configuration
   action: template src=mon/${ansible_hostname}.conf.j2 dest=/etc/mon/mon.cf owner=root group=root mode=0644
   notify:
     - Restart mon
-  when_boolean: ${with_mon}
+  when: ${with_mon}
 
 - name: Install mon (default) configuration
   action: template src=mon/default.j2 dest=/etc/default/mon owner=root group=root mode=0644
   notify:
     - Restart mon
-  when_boolean: ${with_mon}
+  when: ${with_mon}
 
 - name: Install custom mon plugins
   action: copy src=mon/${item}.monitor dest=/etc/mon/mon.d/${item}.monitor owner=root group=root mode=0755
@@ -26,7 +26,7 @@
     - dns
   notify:
     - Restart mon
-  when_boolean: ${with_mon}
+  when: ${with_mon}
 
 - name: Install mon plugins
   action: file src=/usr/lib/mon/mon.d/${item}.monitor path=/etc/mon/mon.d/${item}.monitor state=link
@@ -38,8 +38,8 @@
     - tcp
   notify:
     - Restart mon
-  when_boolean: ${with_mon}
+  when: ${with_mon}
 
 - name: Ensure mon is running
   action: service name=mon state=started
-  when_boolean: ${with_mon}
+  when: ${with_mon}

+ 12 - 12
roles/monitoring/tasks/munin.yml

@@ -1,10 +1,10 @@
 - name: Install munin packages
   action: ${ansible_pkg_mgr} pkg=munin state=installed update_cache=yes
-  when_boolean: ${with_munin}
+  when: ${with_munin}
 
 - name: Install munin configuration
   action: template src=munin/munin.conf.j2 dest=/etc/munin/munin.conf owner=root group=root mode=0644
-  when_boolean: ${with_munin}
+  when: ${with_munin}
 
 - name: Install munin-node packages
   action: ${ansible_pkg_mgr} pkg=${item} state=installed update_cache=yes
@@ -16,57 +16,57 @@
     - libdbd-pg-perl
     - libdbd-mysql-perl
     - liblwp-useragent-determined-perl
-  when_boolean: ${with_munin_node}
+  when: ${with_munin_node}
 
 - name: Create need directories for munin-node configuration
   action: file path=/etc/munin/${item} state=directory owner=root group=root mode=0755
   with_items:
     - plugins
     - plugin-conf.d
-  when_boolean: ${with_munin_node}
+  when: ${with_munin_node}
 
 - name: Install munin node configuration
   action: template src=munin/munin-node.conf.j2 dest=/etc/munin/munin-node.conf owner=root group=root mode=0644
   notify:
     - Restart munin-node
-  when_boolean: ${with_munin_node}
+  when: ${with_munin_node}
 
 - name: Install munin node plugins configuration
   action: template src=munin/munin-node.conf.plugins.j2 dest=/etc/munin/plugin-conf.d/munin-node owner=root group=root mode=0644
   notify:
     - Restart munin-node
-  when_boolean: ${with_munin_node}
+  when: ${with_munin_node}
 
 - name: Autoconfigure munin-node plugins
   action: munin_node_autoconf families=auto,manual,contrib excludes=apc_nis,apt,apt_all,port_,ipmi_fans,ipmi_power,ipmi_temp,ntp_,ircu,ntp_kernel_err,ntp_kernel_pll_freq,ntp_kernel_pll_off,ntp_offset,ntp_states
   notify:
     - Restart munin-node
-  when_boolean: ${with_munin_node}
+  when: ${with_munin_node}
 
 - name: Install nginx virtual host for munin (sites-available)
   action: template src=munin/nginx_vhost.j2 dest=/etc/nginx/sites-available/munin owner=root group=root mode=0644
   notify:
     - Reload nginx for munin
-  when_boolean: ${with_munin} and ${with_nginx}
+  when: ${with_munin} and ${with_nginx}
 
 - name: Install nginx virtual host for munin (sites-enabled)
   action: file src=/etc/nginx/sites-available/munin path=/etc/nginx/sites-enabled/munin state=link
   notify:
     - Reload nginx for munin
-  when_boolean: ${with_munin} and ${with_nginx}
+  when: ${with_munin} and ${with_nginx}
 
 - name: Install apache2 virtual host for munin (sites-available)
   action: template src=munin/apache2_vhost.j2 dest=/etc/apache2/sites-available/munin owner=root group=root mode=0644
   notify:
     - Reload apache2 for munin
-  when_boolean: ${with_munin} and ${with_apache2}
+  when: ${with_munin} and ${with_apache2}
 
 - name: Install apache2 virtual host for munin (sites-enabled)
   action: file src=/etc/apache2/sites-available/munin path=/etc/apache2/sites-enabled/munin state=link
   notify:
     - Reload apache2 for munin
-  when_boolean: ${with_munin} and ${with_apache2}
+  when: ${with_munin} and ${with_apache2}
 
 - name: Ensure munin-node is running
   action: service name=munin-node state=started
-  when_boolean: ${with_munin_node}
+  when: ${with_munin_node}

+ 9 - 9
roles/webserver/tasks/apache2.yml

@@ -1,45 +1,45 @@
 - name: Install apache2 packages
   action: ${ansible_pkg_mgr} pkg=apache2 state=installed update_cache=yes
-  when_boolean: ${with_apache2}
+  when: ${with_apache2}
 
 - name: Install apache2 basic security configuration
   action: template src=apache2/conf.d/security.j2 dest=/etc/apache2/conf.d/security owner=root group=root mode=0644
   notify:
     - Reload apache2
-  when_boolean: ${with_apache2}
+  when: ${with_apache2}
 
 - name: Install mod_php5 packages for apache2
   action: ${ansible_pkg_mgr} pkg=libapache2-mod-php5 state=installed update_cache=yes
-  when_boolean: ${with_apache2} and ${with_apache2_modphp5}
+  when: ${with_apache2} and ${with_apache2_modphp5}
 
 - name: Create basic authentication file for admin (apache2)
   action: template src=apache2/auth_admin.j2 dest=/etc/apache2/auth_admin owner=root group=www-data mode=0640
-  when_boolean: ${with_apache2}
+  when: ${with_apache2}
 
 - name: Install PHPMyAdmin virtual host for apache2 (sites-available)
   action: template src=apache2/pma_vhost.j2 dest=/etc/apache2/sites-available/pma owner=root group=root mode=0644
   notify:
     - Reload apache2
-  when_boolean: ${with_phpmyadmin} and ${with_apache2}
+  when: ${with_phpmyadmin} and ${with_apache2}
 
 - name: Install PHPMyAdmin virtual host for apache2 (sites-enabled)
   action: file src=/etc/apache2/sites-available/pma path=/etc/apache2/sites-enabled/pma state=link
   notify:
     - Reload apache2
-  when_boolean: ${with_phpmyadmin} and ${with_apache2}
+  when: ${with_phpmyadmin} and ${with_apache2}
 
 - name: Install PHP system checks virtual host for apache2 (sites-available)
   action: template src=apache2/sys_vhost.j2 dest=/etc/apache2/sites-available/sys owner=root group=root mode=0644
   notify:
     - Reload apache2
-  when_boolean: ${with_php} and ${with_apache2}
+  when: ${with_php} and ${with_apache2}
 
 - name: Install PHP system checks virtual host for apache2 (sites-enabled)
   action: file src=/etc/apache2/sites-available/sys path=/etc/apache2/sites-enabled/sys state=link
   notify:
     - Reload apache2
-  when_boolean: ${with_php} and ${with_apache2}
+  when: ${with_php} and ${with_apache2}
 
 - name: Ensure apache2 is running
   action: service name=apache2 state=started
-  when_boolean: ${with_apache2}
+  when: ${with_apache2}

+ 6 - 6
roles/webserver/tasks/fpm.yml

@@ -1,31 +1,31 @@
 - name: Install php5-fpm package
   action: ${ansible_pkg_mgr} pkg=php5-fpm state=installed update_cache=yes
-  when_boolean: ${with_fpm}
+  when: ${with_fpm}
 
 - name: Install php5-fpm init script config file
   action: template src=fpm/default.j2 dest=/etc/default/php5-fpm owner=root group=root mode=0644
   notify:
       - Restart php5-fpm
-  when_boolean: ${with_fpm}
+  when: ${with_fpm}
 
 - name: Install php5-fpm configuration file
   action: template src=fpm/php-fpm-custom.conf.j2 dest=/etc/php5/fpm/php-fpm-custom.conf owner=root group=root mode=0644
   notify:
       - Restart php5-fpm
-  when_boolean: ${with_fpm}
+  when: ${with_fpm}
 
 - name: Install nginx config files for php5-fpm (fpm servers pool)
   action: template src=fpm/nginx/fpm-pool.conf.j2 dest=/etc/nginx/conf.d/fpm-pool.conf owner=root group=root mode=0644
   notify:
       - Reload nginx
-  when_boolean: ${with_fpm} and ${with_nginx}
+  when: ${with_fpm} and ${with_nginx}
 
 - name: Install nginx config files for php5-fpm (fpm fastcgi config)
   action: template src=fpm/nginx/fastcgi_pass_fpm.j2 dest=/etc/nginx/fastcgi_pass_fpm owner=root group=root mode=0644
   notify:
       - Reload nginx
-  when_boolean: ${with_fpm} and ${with_nginx}
+  when: ${with_fpm} and ${with_nginx}
 
 - name: Ensure php5-fpm is running
   action: service name=php5-fpm state=started
-  when_boolean: ${with_fpm}
+  when: ${with_fpm}

+ 11 - 11
roles/webserver/tasks/nginx.yml

@@ -1,18 +1,18 @@
 - name: Install nginx package
   action: ${ansible_pkg_mgr} pkg=nginx state=installed update_cache=yes
-  when_boolean: ${with_nginx}
+  when: ${with_nginx}
 
 - name: Install nginx default file configuration
   action: template src=nginx/default.j2 dest=/etc/default/nginx owner=root group=root mode=0644
   notify:
     - Restart nginx
-  when_boolean: ${with_nginx}
+  when: ${with_nginx}
 
 - name: Install nginx configuration
   action: template src=nginx/nginx.conf.j2 dest=/etc/nginx/nginx.conf owner=root group=root mode=0644
   notify:
     - Restart nginx
-  when_boolean: ${with_nginx}
+  when: ${with_nginx}
 
 - name: Install additional nginx configuration params (conf.d/)
   action: template src=nginx/conf.d/${item}.conf.j2 dest=/etc/nginx/conf.d/${item}.conf owner=root group=root mode=0644
@@ -20,7 +20,7 @@
     - status
   notify:
     - Reload nginx
-  when_boolean: ${with_nginx}
+  when: ${with_nginx}
 
 - name: Install additional nginx configuration params (vhost_*)
   action: template src=nginx/vhost_${item}.j2 dest=/etc/nginx/vhost_${item} owner=root group=root mode=0644
@@ -31,36 +31,36 @@
     - protect-files
   notify:
     - Reload nginx
-  when_boolean: ${with_nginx}
+  when: ${with_nginx}
 
 - name: Create basic authentication file for admin (nginx)
   action: template src=nginx/auth_admin.j2 dest=/etc/nginx/auth_admin owner=root group=www-data mode=0640
-  when_boolean: ${with_nginx}
+  when: ${with_nginx}
 
 - name: Install PHPMyAdmin virtual host for nginx (sites-available)
   action: template src=nginx/pma_vhost.j2 dest=/etc/nginx/sites-available/pma owner=root group=root mode=0644
   notify:
     - Reload nginx
-  when_boolean: ${with_phpmyadmin} and ${with_nginx}
+  when: ${with_phpmyadmin} and ${with_nginx}
 
 - name: Install PHPMyAdmin virtual host for nginx (sites-enabled)
   action: file src=/etc/nginx/sites-available/pma path=/etc/nginx/sites-enabled/pma state=link
   notify:
     - Reload nginx
-  when_boolean: ${with_phpmyadmin} and ${with_nginx}
+  when: ${with_phpmyadmin} and ${with_nginx}
 
 - name: Install PHP system checks virtual host for nginx (sites-available)
   action: template src=nginx/sys_vhost.j2 dest=/etc/nginx/sites-available/sys owner=root group=root mode=0644
   notify:
     - Reload nginx
-  when_boolean: ${with_php} and ${with_nginx}
+  when: ${with_php} and ${with_nginx}
 
 - name: Install PHP system checks virtual host for nginx (sites-enabled)
   action: file src=/etc/nginx/sites-available/sys path=/etc/nginx/sites-enabled/sys state=link
   notify:
     - Reload nginx
-  when_boolean: ${with_php} and ${with_nginx}
+  when: ${with_php} and ${with_nginx}
 
 - name: Ensure nginx is running
   action: service name=nginx state=started
-  when_boolean: ${with_nginx}
+  when: ${with_nginx}

+ 8 - 8
roles/webserver/tasks/php.yml

@@ -7,32 +7,32 @@
     - php5-intl
     - php5-mcrypt
     - php-mime-type
-  when_boolean: ${with_php}
+  when: ${with_php}
 
 - name: Instal local PHP configuration
   action: template src=php/php-config.ini.j2 dest=/etc/php5/conf.d/99-local-config.ini owner=root group=root mode=0644
-  when_boolean: ${with_php}
+  when: ${with_php}
 
 - name: Create system checks directory /etc/php5/syscheck.d
   action: file path=/etc/php5/syscheck.d owner=root group=root mode=0755 state=directory
-  when_boolean: ${with_php}
+  when: ${with_php}
 
 - name: Install phpinfo system check
   action: template src=php/phpinfo.php dest=/etc/php5/syscheck.d/index.php owner=root group=root mode=0644
-  when_boolean: ${with_php}
+  when: ${with_php}
 
 - name: Install PHP APC extension
   action: ${ansible_pkg_mgr} pkg=php-apc state=installed update_cache=yes
-  when_boolean: ${with_php_apc}
+  when: ${with_php_apc}
 
 - name: Install php-apc system check
   action: template src=php/apc.php dest=/etc/php5/syscheck.d/apc.php owner=root group=root mode=0644
-  when_boolean: ${with_php_apc}
+  when: ${with_php_apc}
 
 - name: Install MySQL extension for PHP
   action: ${ansible_pkg_mgr} pkg=php5-mysqlnd state=installed update_cache=yes
-  when_boolean: ${with_mysql} and ${with_php}
+  when: ${with_mysql} and ${with_php}
 
 - name: Install PHPMyAdmin
   action: ${ansible_pkg_mgr} pkg=phpmyadmin state=installed update_cache=yes
-  when_boolean: ${with_phpmyadmin}
+  when: ${with_phpmyadmin}