private static void apply_minion_config_DECAC(Session session, string minion_config)
        {
            // Precondition: parameter minion_config contains the content of the MINION_CONFI property and is not empty
            // Remove all other config
            session.Log("...apply_minion_config_DECAC BEGIN");
            string conffolder           = MinionConfigurationUtilities.get_property_DECAC(session, "conffolder");
            string minion_d_conf_folder = MinionConfigurationUtilities.get_property_DECAC(session, "minion_d_conf_folder");
            // Write conf/minion
            string lines = minion_config.Replace("^", Environment.NewLine);

            MinionConfigurationUtilities.Writeln_file(session, conffolder, "minion", lines);
            // Remove conf/minion_id
            string minion_id = Path.Combine(conffolder, "minion_id");

            session.Log("...searching " + minion_id);
            if (File.Exists(minion_id))
            {
                File.Delete(minion_id);
                session.Log("...deleted   " + minion_id);
            }
            // Remove conf/minion.d/*.conf
            session.Log("...searching *.conf in " + minion_d_conf_folder);
            if (Directory.Exists(minion_d_conf_folder))
            {
                var conf_files = System.IO.Directory.GetFiles(minion_d_conf_folder, "*.conf");
                foreach (var conf_file in conf_files)
                {
                    File.Delete(conf_file);
                    session.Log("...deleted   " + conf_file);
                }
            }
            session.Log(@"...apply_minion_config_DECAC END");
        }
Example #2
0
        private static void save_config_DECAC(Session session)
        {
            session.Log(@"...save_config_DECAC");
            string kwargs_in_commata = MinionConfigurationUtilities.get_property_DECAC(session, "minion_config");

            if (kwargs_in_commata.Length > 0)
            {
                string lines = kwargs_in_commata.Replace("^", Environment.NewLine);
                MinionConfigurationUtilities.Writeln_file(session, @"C:\salt\conf", "minion", lines);
            }
        }
Example #3
0
        static private void append_to_config_DECAC(Session session, string key, string value)
        {
            string MINION_CONFIGDIR = MinionConfigurationUtilities.getConfigdDirectoryLocation_DECAC(session);

            if (session.CustomActionData["config_type"] == "New")
            {
                //CONFIG_TYPE New creates a minion.d/*.conf file
                MinionConfigurationUtilities.Writeln_file(session, MINION_CONFIGDIR, key + ".conf", key + ": " + value);
            }
            else
            {
                // Shane: CONFIG_TYPES 1-3 change only the MINION_CONFIGFILE, not the minion.d/*.conf files, because the admin knows what he is doing.
                insert_value_after_comment_or_end_in_minionconfig_file(session, key, value);
            }
        }
Example #4
0
        private static void save_id_function_DECAC(Session session)
        {
            session.Log(@"...save_id_function_DECAC");
            string minion_id_function = MinionConfigurationUtilities.get_property_DECAC(session, "minion_id_function");

            if (minion_id_function.Length > 0)
            {
                string filepath    = @"c:\salt\var\cache\salt\minion\extmods\modules";
                string filename    = @"id_function.py";
                string filecontent = @"import socket
def id_function():
    return " + minion_id_function;
                MinionConfigurationUtilities.Writeln_file(session, filepath, filename, filecontent);
            }
        }