wmdeit-cf-wmdelib/vimbadmin.cf

133 lines
3.8 KiB
CFEngine3

#
#
#
bundle agent vimbadmin(cfg)
{
vars:
"r" int => randomint(1,5),
handle => "rand_assigned";
"vsettings[resources.doctrine2.connection.options.driver]" string => "'$(cfg[db_driver])'";
"vsettings[resources.doctrine2.connection.options.dbname]" string => "'$(cfg[db_name])'";
"vsettings[resources.doctrine2.connection.options.user]" string => "'$(cfg[db_user])'";
"vsettings[resources.doctrine2.connection.options.password]" string => "'$(cfg[db_pass])'";
"vsettings[resources.doctrine2.connection.options.host]" string => "'$(cfg[db_host])'";
"vsettings[securitysalt]" string => "'$(cfg[security_salt])'";
"vsettings[resources.auth.oss.rememberme.salt]" string => "'$(cfg[rememberme_salt])'";
"vsettings[defaults.mailbox.password_salt]" string => "'$(cfg[password_salt])'";
"vsettings[skipInstallPingback]" string => "1";
"vsettings[server.email.name]" string => "$(cfg[server_email_name])";
"vsettings[server.email.address]" string => "$(cfg[server_email_address])";
classes:
"vimbadmin_checked_out" expression => fileexists("$(cfg[dst_dir])/.git");
"pull_it" expression => eval("1 == $(r)","class","infix"),
depends_on => {"rand_assigned"};
"vimbadmin_reconfigure" expression =>
or(
not(fileexists("$(sys.workdir)/data/agent/vimbadmin/configured.txt")),
not(fileexists("$(cfg[install_dir])/public"))
);
vars:
"clone_cmd" string => "$(git.exe) clone $(cfg[clone_args]) $(cfg[src]) $(cfg[dst_dir])";
files:
"$(sys.workdir)/data/public/."
create => "true",
perms => m(755),
handle => "vimbadmin_workdir_created";
"$(sys.workdir)/data/public/vimbadmin.tgz"
copy_from => sync_cp("$(cfg[src_tgz])","$(sys.policy_hub)"),
handle => "vimbadmin_tgz_copied",
depends_on => {"vimbadmin_workdir_created"},
perms => m(644),
classes => if_repaired(vimbadmin_reconfigure);
"$(cfg[install_dir])/public/.htaccess"
copy_from => local_cp("$(cfg[install_dir])/public/.htaccess.dist"),
perms => mog("644","root","root"),
depends_on => {"vimbadmin_untarred"},
handle => "vimbadmin_htaccess_copied";
"$(cfg[install_dir])/application/configs/application.ini"
copy_from => seed_cp("$(cfg[install_dir])/application/configs/application.ini.dist"),
perms => mog("644","root","root"),
depends_on => {"vimbadmin_untarred"},
handle => "vimbadmin_appini_copied";
"$(cfg[install_dir])/application/configs/application.ini"
edit_line => set_variable_values("vimbadmin.vsettings"),
handle => "vimbadmin_appini_edited",
depends_on => { "vimbadmin_appini_copied" };
vimbadmin_reconfigure::
"$(sys.workdir)/data/agent/vimbadmin/configured.txt"
depends_on => { "vimbadmin_tgz_copied" },
delete => tidy;
"$(sys.workdir)/data/agent/vimbadmin/configured.txt"
depends_on => { "vimbadmin_composed" },
create => "true",
content => "ok";
commands:
"!mysql_$(cfg[db_name])_admin_exists"::
"cd $(cfg[install_dir]) && ./bin/doctrine2-cli.php orm:schema-tool:create "
contain => wmde_cmd_useshell,
depends_on => {"vimbadmin_appini_edited"};
vimbadmin_reconfigure::
"/bin/sh"
args => "-c '/usr/bin/tar xf $(sys.workdir)/data/public/vimbadmin.tgz --strip-components=1 -C $(cfg[install_dir])'",
handle => "vimbadmin_untarred",
contain => vimbadmin_cmd;
"/bin/sh"
# args => "-c 'cd $(cfg[install_dir]) && $(php_composer.exe) -q -n create-project --prefer-dist --no-dev opensolutions/vimbadmin'",
args => "-c 'cd $(cfg[install_dir]) && $(php_composer.exe) install -q --prefer-dist --no-dev",
handle => "vimbadmin_composed",
contain => vimbadmin_cmd;
#"/bin/sh"
#args => '-c $(php
!vimbadmin_reconfigure::
"/bin/true"
inform => "false",
handle => "vimbadmin_untarred";
methods:
"any" usebundle => php_composer;
"any" usebundle => mysql_table_exists(@(cfg),"admin");
reports:
}
body contain vimbadmin_cmd
{
exec_owner => "www-data";
exec_group => "www-data";
}