Last active
December 19, 2015 01:39
-
-
Save kreczko/5877191 to your computer and use it in GitHub Desktop.
Code for exec with onlyif example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exec { 'create-apel-mysql-tables': | |
command => '/usr/bin/mysql --defaults-file=/root/.my.cnf apelclient < /usr/share/apel/client.sql', | |
require => [ | |
File['/usr/share/apel/client.sql'], | |
Class["mysql"], | |
Class["mysql::server"], | |
Database[$mysql_database]], | |
# needs check if already exists, otherwise will wipe the tables! | |
onlyif => 'exit $(`/usr/bin/mysql --defaults-file=/root/.my.cnf -e "use apelclient; show tables;SELECT FOUND_ROWS();" 2>&1 | cut -f1 | egrep "^(0|[1-9][0-9]*)$"`)' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment