Forum: CFEngine Help Subject: multiple command sequences as a variable Author: xwangbu Link to topic: https://cfengine.com/forum/read.php?3,24113,24113#msg-24113
how to define multiple commands as a variable? i'm trying to compress a bundle so that it works for Red Hat and AIX systems. the var entries are something like this: redhat:: "sshd_restart" string => "/sbin/service sshd restart"; aix:: "sshd_restart" string => "/usr/bin/stopsrc -s sshd"; "/usr/bin/startsrc -s sshd"; i've also tried: "sshd_restart" string => "/usr/bin/stopsrc -s sshd; /usr/bin/startsrc -s sshd"; but i just get a syntax error when testing the bundle: cf3> -> This promise has already been verified cf3> -> Edited file /tmp/sshd_config cf3> ?> defining promise result class reload_sshd cf3> -> Handling file existence constraints on /tmp/sshd_config cf3> -> File permissions on /tmp/sshd_config as promised cf3> cf3> ......................................................... cf3> Promise handle: cf3> Promise made by: /tmp/sshd_config -> SSH Access control list cf3> cf3> Comment: Append common ACL for sshd config file cf3> ......................................................... cf3> cf3> -> Using literal pathtype for /tmp/sshd_config cf3> -> This promise has already been verified cf3> cf3> ========================================================= cf3> commands in bundle prod_sshdconfig (1) cf3> ========================================================= cf3> cf3> -> Promiser string contains a valid executable (/usr/bin/stopsrc) - ok cf3> cf3> ......................................................... cf3> Promise handle: sshd_restart cf3> Promise made by: /usr/bin/stopsrc -s sshd; /usr/bin/startsrc -s sshd cf3> cf3> Comment: restart sshd. cf3> ......................................................... cf3> cf3> -> Executing '/usr/bin/stopsrc -s sshd; /usr/bin/startsrc -s sshd' ...(timeout=-678,owner=-1,group=-1) cf3> -> (Setting umask to 77) cf3> !! Finished command related to promiser "/usr/bin/stopsrc -s sshd; /usr/bin/startsrc -s sshd" -- an error occurred (returned 1) cf3> Q: "...in/stopsrc -s s": 0513-040 Usage is one of: Q: "...in/stopsrc -s s": stopsrc [-h host] [-f | -c] -a Q: "...in/stopsrc -s s": stopsrc [-h host] [-f | -c] -g group_name Q: "...in/stopsrc -s s": stopsrc [-h host] [-f | -c] -s subsystem_name Q: "...in/stopsrc -s s": stopsrc [-h host] [-f | -c] -p subsystem_pid Q: "...in/stopsrc -s s": stopsrc [-h host] [-f] -t subserver_type [-o subserver_object] [-p subsystem_pid] Q: "...in/stopsrc -s s": stopsrc [-h host] [-f] -t subserver_type [-P subserver_pid] [-p subsystem_pid] cf3> I: Last 7 quoted lines were generated by promiser "/usr/bin/stopsrc -s sshd; /usr/bin/startsrc -s sshd" cf3> -> Completed execution of /usr/bin/stopsrc -s sshd; /usr/bin/startsrc -s sshd cf3> so i settled with a wrapper script to have the sequence for AIX: bundle agent prod_sshdconfig { vars: redhat:: "sftp_cmd_line" string => "Subsystem sftp /usr/libexec/openssh/sftp-server"; "sshd_restart" string => "/sbin/service sshd restart"; aix:: "sftp_cmd_line" string => "Subsystem sftp /usr/sbin/sftp-server"; "sshd_restart" string => "/usr/sbin/restart_service.ksh sshd"; files: "/etc/ssh/sshd_config" comment => "Append common ACL for sshd config file", create => "true", copy_from => local_cp_digest("$(g.master_modules)/sshd/sshd_config_asia"), edit_line => append_if_no_lines("$(sftp_cmd_line)"), perms => set_mog_perms("0600", "root"), classes => if_repaired("reload_sshd"); commands: reload_sshd:: "$(sshd_restart)" handle => "sshd_restart", comment => "restart sshd."; } this is 3.2.1 btw. thanks. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine