cfengine-yum

50 views
Skip to first unread message

Xander Cage

unread,
Aug 22, 2017, 10:35:31 AM8/22/17
to help-cfengine
i am tinkering with mr. andersons yum policy (https://github.com/nickanderson/cfengine-yum) and of course i'm unable to wrap my head around it. it just want the yum repo configs generated not more.

my policy:

bundle agent b0026_control_rpm_housekeeper_yum
{

    meta
:
   
"tags"  slist => { "itsv" };

    classes
:

       
"RPM_ROLLOUT_HOST"    expression => regcmp(".*", "$(itsv_hostgroups.LPAR_NAME)"),
                              comment    
=> "gradually enlarge Rollout-Base ..";

       
"YUM_PERZL_ENABLED"   expression => fileexists("/opt/freeware/etc/yum/repos.d/perzl-org.repo");


    methods
:

   
!am_policy_hub.RPM_ROLLOUT_HOST.YUM_PERZL_ENABLED.SPARE_DAILY::

       
"rpm_housekeeper_yum"        usebundle      => rpm_minion,
                                     comment        
=> "keep all RPM versions the same accross all installations",
                                     action        
=> if_elapsed_week;

         
"repos" usebundle => yum_repos_d("purge", @(yum_repository_definitions.data));
         
"rpm_minion" usebundle => rpm_minion;


}

bundle agent rpm_minion
{


    vars
:

             
"wanted_packages" slist => { "bash",
                                           
"bzip2",
                                           
"cpio",
                                           
"curl",
                                           
"expat",
                                           
"gawk",
                                           
"grep",
                                           
"gzip",
                                           
"info",
                                           
"joe",
                                           
"less",
                                           
"lzo",
                                           
"nagios-plugins",
                                           
"openldap",
                                           
"openssl",
                                           
"pcre",
                                           
"perl",
                                           
"readline",
                                           
"rlwrap",
                                           
"rsync",
                                           
"screen",
                                           
"sed",
                                           
"tar",
                                           
"unzip-64bit",
                                           
"vim-common",
                                           
"vim-enhanced",
                                           
"wget",
                                           
"xz",
                                           
"zip",
                                           
"zlib" };


           
"unwanted_packages" slist => { "xmahjongg" };


           
"proftpd_config"  slist => { "/etc/proftpd.conf", "/etc/ftpusers" };

   classes
:

       
"SUBVERSION_EXCLUDE"  expression => strcmp("MVBMIGTA2-APPL", "$(itsv_hostgroups.LPAR_NAME)"),
                              comment    
=> "already upgraded beyond version 1.6, downgrade will break functionality";

       
"DEVELOPMENT_REPO_ENABLED"  expression => strcmp("AIXBUILDHOST|AIXTEST01", "$(itsv_hostgroups.LPAR_NAME)"),
                                   comment    
=> "buildhost and friends";

       
"PROFTPD_CONFIG_EXISTS" expression => filesexist("@(proftpd_config)");

  commands
:

   
"/usr/bin/rpm -q subversion"  classes => set_class_on_return_codes("SUBVERSION_HOST", "0");
   
"/usr/bin/rpm -q proftpd"     classes => set_class_on_return_codes("PROFTPD_HOST", "0");

  vars
:

   aix_7_1
.SUBVERSION_INSTALL_OK::

       
"perzl-org"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl-org": {
                    "id": { "value": "perzl.org"},
                    "name": { "value": "perzl.org_AIX_7.1"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix71"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);

       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix71"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);


   aix_7_2
.SUBVERSION_INSTALL_OK::

   
"perzl-org"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl-org": {
                    "id": { "value": "perzl.org"},
                    "name": { "value": "perzl.org_AIX_7.2"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix72"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);

       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix72"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);


     aix_7_1
.DEVELOPMENT_REPO_ENABLED::

       
"perzl-org"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl-org": {
                    "id": { "value": "perzl.org"},
                    "name": { "value": "perzl.org_AIX_7.1"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix71"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);

       
"perzl_supplemental_dev"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl_supplemental_dev": {
                    "id": { "value": "perzl_supplemental_dev"},
                    "name": { "value": "perzl_supplemental_dev"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental_dev/aix71"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);


   aix_7_2
.DEVELOPMENT_REPO_ENABLED::


       
"perzl-org"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl-org": {
                    "id": { "value": "perzl.org"},
                    "name": { "value": "perzl.org_AIX_7.2"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix72"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);

       
"perzl_supplemental_dev"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl_supplemental_dev": {
                    "id": { "value": "perzl_supplemental_dev"},
                    "name": { "value": "perzl_supplemental_dev"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental_dev/aix72"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);


      aix_7_1
::

       
"perzl-org"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl-org": {
                    "id": { "value": "perzl.org"},
                    "name": { "value": "perzl.org_AIX_7.1"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix71"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);

       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix71"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);




   aix_7_2
::

       
"perzl-org"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl-org": {
                    "id": { "value": "perzl.org"},
                    "name": { "value": "perzl.org_AIX_7.2"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix72"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);


       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson('{
                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix72"},
                    "gpgcheck": { "value": "0"},
                    "gpgkey": { "value": "" }
                  }
                }'
);




   files
:

     
"/etc/sudoers_cfesave"
                           copy_from    
=> local_cp("/etc/sudoers"),
                           classes
=> if_ok("SUDOERS_SAVE_OK");



  PROFTPD_HOST
.PROFTPD_CONFIG_EXISTS::

       
"/etc/proftpd.conf_cfesave"
                                   copy_from
=> local_cp("/etc/proftpd.conf"),
                                   classes
=> if_ok("PROFTPD_CF_SAVE_OK");

       
"/etc/ftpusers_cfesave"
                                       copy_from
=> local_cp("/etc/ftpusers"),
                                       classes
=> if_ok("FTPUSERS_SAVE_OK");



     packages
:


             
"$(wanted_packages)"
                                     policy
=> "present",
                                     package_module
=> yum,
                                     version
=> "latest",
                                     classes
=> if_ok("YUM_INSTALL_OK");

             
"$(unwanted_packages)"
                                     policy
=> "absent",
                                     package_module
=> yum,
                                     classes
=> if_ok("YUM_UNINSTALL_OK");

    PROFTPD_HOST
.PROFTPD_CF_SAVE_OK.FTPUSERS_SAVE_OK::

                   
"proftpd"
                                     policy
=> "present",
                                     package_module
=> yum,
                                     version
=> "latest",
                                     classes
=> if_ok("PROFTPD_INSTALL_OK");


   
!SUBVERSION_EXCLUDE.SUBVERSION_HOST::

               
"subversion"          policy => "present",
                                     package_module
=> yum,
                                     version
=> "1.6.23-1",
                                     classes
=> if_ok("SUBVERSION_INSTALL_OK");
    SUDOERS_SAVE_OK
::

               
"sudo"               policy => "present",
                                    package_module
=> yum,
                                    version
=> "latest",
                                    classes
=> if_ok("SUDO_INST_OK");

    files
:

    SUDO_INST_OK
::

             
"/etc/sudoers"
                            copy_from    
=> local_cp("/etc/sudoers_cfesave");

   PROFTPD_INSTALL_OK
::

               
"/etc/proftpd.conf"
                                   copy_from
=> local_cp("/etc/proftpd.conf_cfesave");

               
"/etc/ftpusers"
                                   copy_from
=> local_cp("/etc/ftpusers_cfesave");


  any
::
     
# Find all of the repo definitions (variables in this bundle tagged with "yum_repos_d")
     
"repo_defs" slist => variablesmatching("$(this.namespace):$(this.bundle)\..*", "yum_repos_d");

     
# Now we merge them all together into a single data var
     
"data" data => parsejson('[]');
     
"data" data => mergedata(data, $(repo_defs));

     
# These variables are only useful when debugging
     DEBUG
|DEBUG_yum_repository_definitions::
       
"s_data" string => format("%S", data);
       
"repo_ids" slist => getindices(data);
       
"repo_def_count" int => length(repo_ids);



    reports
:

        YUM_INSTALL_OK
:: "yum install of desired packages ok ..";
        YUM_UNINSTALL_OK
:: "yum erase of unwanted packages ok ..";
        PROFTPD_INSTALL_OK
:: "package proftpd installed";
        SUBVERSION_INSTALL_OK
:: "package subversion installed";
        SUDO_INST_OK
:: "package sudo installed";
     DEBUG
|DEBUG_yum_repo_robot::
       
"DEBUG $(this.bundle) YES THIS ONE";
       
"$(const.t) Found '$(repo_def_count)' yum repo client definitions";
       
"$(const.t) Found yum_repos_d client definition for '$(repo_ids)'";
       
"$(const.t) Serialized Data: '$(s_data)'";

        any
:: "finished  ..";
}



the error:

root@aixtest01: /root # /var/cfengine/bin/cf-agent -K -D SPARE_DAILY -b b0026_control_rpm_housekeeper_yum
/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf:335:0: error: Promise type files has unknown attribute slist
/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf:338:0: error: Promise type files has unknown attribute data
/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf:339:0: error: Promise type files has unknown attribute data
/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf:343:0: error: Promise type files has unknown attribute string
/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf:344:0: error: Promise type files has unknown attribute slist
/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf:345:0: error: Promise type files has unknown attribute int
   error
: There are syntax errors in policy files
Enter code here...



Nicolas Charles

unread,
Aug 22, 2017, 11:17:38 AM8/22/17
to Xander Cage, help-cfengine
Hi Xander,

You have an issue at the end of your policy: the part

  any::
      # Find all of the repo definitions (variables in this bundle tagged with "yum_repos_d")
      "repo_defs" slist => variablesmatching("$(this.namespace):$(this.bundle)\..*", "yum_repos_d");

      # Now we merge them all together into a single data var
      "data" data => parsejson('[]');
      "data" data => mergedata(data, $(repo_defs));

     # These variables are only useful when debugging
     DEBUG|DEBUG_yum_repository_definitions::
       "s_data" string => format("%S", data);
       "repo_ids" slist => getindices(data);
       "repo_def_count" int => length(repo_ids);


should not be in the "files:" promises type part, but in the vars: section.
It looks like a bad copy and paste...

Nicolas
--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.


-- 
Nicolas CHARLES

Nick Anderson

unread,
Aug 22, 2017, 11:26:05 AM8/22/17
to help-c...@googlegroups.com
Forgot to copy the list.

---------- Forwarded message ----------
From: Nick Anderson <nick.a...@northern.tech>
Date: Tue, Aug 22, 2017 at 10:02 AM
Subject: Re: [help-cfengine] cfengine-yum
To: Xander Cage <christia...@itsv.at>


Hi Xander,

Your syntax error is here:


```
    files
:


    SUDO_INST_OK
::

              
"/etc/sudoers"
                            copy_from    
=> local_cp("/etc/sudoers_cfesave");

   PROFTPD_INSTALL_OK
::

               
"/etc/proftpd.conf"
                                   copy_from 
=>local_cp("/etc/proftpd.conf_cfesave");

               
"/etc/ftpusers"
                                   copy_from 
=>local_cp("/etc/ftpusers_cfesave");


  any
::
      
# Find all of the repo definitions (variables in this bundle tagged with "yum_repos_d")
      
"repo_defs" slist => variablesmatching("$(this.namespace):$(this.bundle)\..*", "yum_repos_d");
```

You have a files type promise section, and after the any:: class you seem to be defining a list. Before that varibale definition you need to specify vars: type promise.

I hope this helps.

--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengine+unsubscribe@googlegroups.com.

Xander Cage

unread,
Aug 23, 2017, 2:54:11 AM8/23/17
to help-c...@googlegroups.com
did some editing and indeed made some progress.

at first it did not like the dash between "perzl-org", replaced it with a underscore which quiesed this error ->

 error: Variable identifier contains illegal characters
   error: Promise belongs to bundle 'rpm_minion' in file '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf' near line 91
   error: Variable identifier contains illegal characters
   error: Promise belongs to bundle 'rpm_minion' in file '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf' near line 91
   error: Variable identifier contains illegal characters
   error: Promise belongs to bundle 'rpm_minion' in file '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf' near line 204
   error: Variable identifier contains illegal characters
   error: Promise belongs to bundle 'rpm_minion' in file '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf' near line 204

after moving the bespoken any:: part up to the vars section the former errors are gone.
 but up comes another one which seems a little bit more complicated ->

Active Memory Expansion        : Disabled
There is no efix data on this system.
  notice: Q: "...sr/bin/rpm -q s": subversion-1.6.23-1.ppc
  notice: Q: "...sr/bin/rpm -q p": package proftpd is not installed
R: yum install of desired packages ok ..
R: yum erase of unwanted packages ok ..
R: package sudo installed
R: rpm_minion YES THIS ONE
R:       Found '2' yum repo client definitions
R:       Found yum_repos_d client definition for 'perzl_supplemental'
R:       Found yum_repos_d client definition for 'perzl_org'
R:       Serialized Data: '{"perzl_org":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_mirror/aix71"},"gpgcheck":{"value":"0"},"gpgkey":{"value":""},"id":{"value":"perzl.org"},"name":{"value":"perzl.org_AIX_7.1"}},"perzl_supplemental":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_supplemental/aix71"},"gpgcheck":{"value":"0"},"gpgkey":{"value":""},"id":{"value":"perzl_supplemental"},"name":{"value":"perzl_supplemental"}}}'
R: finished  ..
R: package subversion installed
   error: Method 'rpm_minion' failed in some repairs
   error: None of the promised groups for '/opt/freeware/etc/yum/repos.d/perzl_supplemental.repo' exist -- see INFO logs for more
   error: None of the promised groups for '/opt/freeware/etc/yum/repos.d/perzl_supplemental.repo' exist -- see INFO logs for more
   error: None of the promised groups for '/opt/freeware/etc/yum/repos.d/perzl.org.repo' exist -- see INFO logs for more
   error: None of the promised groups for '/opt/freeware/etc/yum/repos.d/perzl.org.repo' exist -- see INFO logs for more
   error: Method 'yum_repos_d' failed in some repairs

To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.

Xander Cage

unread,
Aug 23, 2017, 4:23:27 AM8/23/17
to help-cfengine
ok, found the reason for the error.

the group "root" does not exist in aix. changed it to "system", which should solve the issue.

files:
   
"$(yum_repos_d)/$(data_$(repo_ids)[id][value]).repo"
      create
=> "true",
      edit_template
=> "$(this.promise_dirname)/../templates/yum.repo.mustache",
      template_method
=> "mustache",
      edit_defaults
=> empty,
      perms
=> mog("0644", "root", "system"),
      ifvarclass
=> canonify("_have_var_data_$(repo_ids)[id][value]"),
      template_data
=> mergedata("data_$(repo_ids)");

Xander Cage

unread,
Aug 23, 2017, 6:48:17 AM8/23/17
to help-cfengine
so it seems that function wise everything is working. but there is one question left.  the classes based decisions on which repo should be enabled are getting ignored. even when defined on the command line, simply ignored. no matter what, always the same output.

root@aixtest01: /var/cfengine # /var/cfengine/bin/cf-agent -K -D SPARE_DAILY -D SUBVERSION_HOST -D \!DEVELOPMENT_REPO_ENABLED -b b0026_control_rpm_housekeeper_yum

Active Memory Expansion        : Disabled
There is no efix data on this system.
  notice
: Q: "...sr/bin/rpm -q s": subversion-1.6.23-1.ppc
  notice
: Q: "...sr/bin/rpm -q p": package proftpd is not
installed
R
: yum install of desired packages OK
R
: yum erase of unwanted packages OK
R
: package subversion installed OK
R
: package sudo installed OK
R
: rpm_minion YES THIS ONE
R
:       Found '2' yum repo client definitions
R
:       Found yum_repos_d client definition for 'perzl_supplemental'

R
:       Found yum_repos_d client definition for 'perzl_org'

R
:       Serialized Data: '{"perzl_org":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_mirror/aix71"},"enabled":{"value":"1"},"gpgcheck":{"value":"0"},"id":{"value":"perzl_org"},"name":{"value":"perzl_org_AIX_7.1"}},"perzl_supplemental":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_supplemental/aix71"},"enabled":{"value":"1"},"gpgcheck":{"value":"0"},"id":{"value":"perzl_supplemental"},"name":{"value":"perzl_supplemental"}}}'
R
: finished  ..

   error
: Method 'rpm_minion' failed in some repairs


actual version of the promise:


bundle agent b0026_control_rpm_housekeeper_yum
{

    meta
:
   
"tags"  slist => { "itsv" };

    classes
:

       
"RPM_ROLLOUT_HOST"    expression => regcmp(".*", "$(itsv_hostgroups.LPAR_NAME)"),
                              comment    
=> "gradually enlarge Rollout-Base ..";


   commands
:

     
"/usr/bin/yum -q repolist | grep perzl"  classes => set_class_on_return_codes("YUM_PERZL_ENABLED", "0");




    methods
:

   
!am_policy_hub.RPM_ROLLOUT_HOST.YUM_PERZL_ENABLED.SPARE_DAILY::

       
"rpm_housekeeper_yum"        usebundle      => rpm_minion,
                                     comment        
=> "keep all RPM versions the same accross all installations",
                                     action        
=> if_elapsed_week;


         
"repos" usebundle => yum_repos_d("purge", @(rpm_minion.data));




   files
:


 vars
:

    aix_7_1
.SUBVERSION_HOST!DEVELOPMENT_REPO_ENABLED::

       
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.1"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);


       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);


   aix_7_2
.SUBVERSION_HOST!DEVELOPMENT_REPO_ENABLED::

   
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.2"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);


       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" },
                    "exclude": { "value": "subversion" }
                  }
                }'
);


     aix_7_1
.DEVELOPMENT_REPO_ENABLED.SUBVERSION_HOST::

       
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.1"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


       
"perzl_supplemental_dev"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental_dev": {
                    "id": { "value": "perzl_supplemental_dev"},
                    "name": { "value": "perzl_supplemental_dev"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental_dev/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


   aix_7_2
.DEVELOPMENT_REPO_ENABLED.SUBVERSION_HOST::


       
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.2"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


       
"perzl_supplemental_dev"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental_dev": {
                    "id": { "value": "perzl_supplemental_dev"},
                    "name": { "value": "perzl_supplemental_dev"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental_dev/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


 aix_7_1
.DEVELOPMENT_REPO_ENABLED.!SUBVERSION_HOST::

       
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.1"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


       
"perzl_supplemental_dev"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental_dev": {
                    "id": { "value": "perzl_supplemental_dev"},
                    "name": { "value": "perzl_supplemental_dev"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental_dev/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


   aix_7_2
.DEVELOPMENT_REPO_ENABLED.!SUBVERSION_HOST::


       
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.2"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


       
"perzl_supplemental_dev"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental_dev": {
                    "id": { "value": "perzl_supplemental_dev"},
                    "name": { "value": "perzl_supplemental_dev"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental_dev/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


  aix_7_1
!SUBVERSION_HOST!DEVELOPMENT_REPO_ENABLED::

       
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.1"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);



       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix71"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);




   aix_7_2
!SUBVERSION_HOST!DEVELOPMENT_REPO_ENABLED::

       
"perzl_org"

        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{
                  "perzl_org": {
                    "id": { "value": "perzl_org"},
                    "name": { "value": "perzl_org_AIX_7.2"},

                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_mirror/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);



       
"perzl_supplemental"
        meta
=> { "yum_repos_d" },
        data
=> parsejson(
'{

                  "perzl_supplemental": {
                    "id": { "value": "perzl_supplemental"},
                    "name": { "value": "perzl_supplemental"},
                    "baseurl": { "value": "http://nimmsag_a/repos/perzl_supplemental/aix72"},
                    "gpgcheck": { "value": "0"},
                    "enabled": { "value": "1" }
                  }
                }'
);


      any
::

     
# Find all of the repo definitions (variables in this bundle tagged with "yum_repos_d")
     
"repo_defs" slist => variablesmatching("$(this.namespace):$(this.bundle)\..*", "yum_repos_d");

     
# Now we merge them all together into a single data var
     
"data" data => parsejson('[]');
     
"data" data => mergedata(data, $(repo_defs));

     
# These variables are only useful when debugging

     
# DEBUG::

       
"s_data" string => format("%S", data);
       
"repo_ids" slist => getindices(data);
       
"repo_def_count" int => length(repo_ids);





    reports
:


        YUM_INSTALL_OK
:: "yum install of desired packages OK";
        YUM_UNINSTALL_OK
:: "yum erase of unwanted packages OK";
        PROFTPD_INSTALL_OK
:: "package proftpd installed OK";
        SUBVERSION_INSTALL_OK
:: "package subversion installed OK";
        SUDO_INST_OK
:: "package sudo installed OK";
     
# DEBUG::

       
"$(this.bundle) YES THIS ONE";
       
"$(const.t) Found '$(repo_def_count)' yum repo client definitions";
       
"$(const.t) Found yum_repos_d client definition for '$(repo_ids)'";
       
"$(const.t) Serialized Data: '$(s_data)'";

        any
:: "finished  ..";
}
Enter code here...

Bas van der Vlies

unread,
Aug 23, 2017, 9:03:45 AM8/23/17
to Xander Cage, help-cfengine
Maybe you find this ueful. Just added our yum mustache/json setup to
cf_surfsara_lib:
* See: https://github.com/basvandervlies/cf_surfsara_lib



On 23/08/2017 12:48, Xander Cage wrote:
> so it seems that function wise everything is working. but there is one
> question left.  the classes based decisions on which repo should be
> enabled are getting ignored. even when defined on the command line,
> simply ignored. no matter what, always the same output.
>
> |
> root@aixtest01:/var/cfengine # /var/cfengine/bin/cf-agent -K -D
> SPARE_DAILY -D SUBVERSION_HOST -D \!DEVELOPMENT_REPO_ENABLED -b
> b0026_control_rpm_housekeeper_yum
> ActiveMemoryExpansion:Disabled
> Thereisnoefix data on thissystem.
>   notice:Q:"...sr/bin/rpm -q s":subversion-1.6.23-1.ppc
>   notice:Q:"...sr/bin/rpm -q p":packageproftpd isnotinstalled
> R:yum install of desired packages OK
> R:yum erase of unwanted packages OK
> R:packagesubversion installed OK
> R:packagesudo installed OK
> R:rpm_minion YES THIS ONE
> R:Found'2'yum repo client definitions
> R:Foundyum_repos_d client definition for'perzl_supplemental'
> R:Foundyum_repos_d client definition for'perzl_org'
> R:SerializedData:'{"perzl_org":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_mirror/aix71"},"enabled":{"value":"1"},"gpgcheck":{"value":"0"},"id":{"value":"perzl_org"},"name":{"value":"perzl_org_AIX_7.1"}},"perzl_supplemental":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_supplemental/aix71"},"enabled":{"value":"1"},"gpgcheck":{"value":"0"},"id":{"value":"perzl_supplemental"},"name":{"value":"perzl_supplemental"}}}'
> R:finished ..
>    error:Method'rpm_minion'failed insome repairs
> "repo_def_count"int=>length(repo_ids);
>
>
>
>
>
>     reports:
>
>         YUM_INSTALL_OK::"yum install of desired packages OK";
>         YUM_UNINSTALL_OK::"yum erase of unwanted packages OK";
>         PROFTPD_INSTALL_OK::"package proftpd installed OK";
>         SUBVERSION_INSTALL_OK::"package subversion installed OK";
>         SUDO_INST_OK::"package sudo installed OK";
> # DEBUG::
> "$(this.bundle) YES THIS ONE";
> "$(const.t) Found '$(repo_def_count)' yum repo client definitions";
> "$(const.t) Found yum_repos_d client definition for '$(repo_ids)'";
> "$(const.t) Serialized Data: '$(s_data)'";
>
>         any::"finished  ..";
> }
> Entercode here...
> |
>
>
>
> |
>
> |
>
>
>
> On Wednesday, August 23, 2017 at 10:23:27 AM UTC+2, Xander Cage wrote:
>
> ok, found the reason for the error.
>
> the group "root" does not exist in aix. changed it to "system",
> which should solve the issue.
>
> |
> files:
> "$(yum_repos_d)/$(data_$(repo_ids)[id][value]).repo"
>       create =>"true",
>       edit_template
> =>"$(this.promise_dirname)/../templates/yum.repo.mustache",
>       template_method =>"mustache",
>       edit_defaults =>empty,
>       perms =>mog("0644","root","system"),
>       ifvarclass =>canonify("_have_var_data_$(repo_ids)[id][value]"),
>       template_data =>mergedata("data_$(repo_ids)");
>
> |
>
>
>
> On Wednesday, August 23, 2017 at 8:54:11 AM UTC+2, Xander Cage wrote:
>
> did some editing and indeed made some progress.
>
> at first it did not like the dash between "perzl-org", replaced
> it with a underscore which quiesed this error ->
>
>  error: Variable identifier contains illegal characters
>    error: Promise belongs to bundle 'rpm_minion' in file
> '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf
> <http://rpm_housekeeper_yum.cf>' near line 91
>    error: Variable identifier contains illegal characters
>    error: Promise belongs to bundle 'rpm_minion' in file
> '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf
> <http://rpm_housekeeper_yum.cf>' near line 91
>    error: Variable identifier contains illegal characters
>    error: Promise belongs to bundle 'rpm_minion' in file
> '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf
> <http://rpm_housekeeper_yum.cf>' near line 204
>    error: Variable identifier contains illegal characters
>    error: Promise belongs to bundle 'rpm_minion' in file
> '/var/cfengine/inputs/itsv/rpm_housekeeper_yum.cf
> <http://rpm_housekeeper_yum.cf>' near line 204
>
> after moving the bespoken any:: part up to the vars section the
> former errors are gone.
>  but up comes another one which seems a little bit more
> complicated ->
>
> |
> Active Memory Expansion        : Disabled
> There is no efix data on this system.
>   notice: Q: "...sr/bin/rpm -q s": subversion-1.6.23-1.ppc
>   notice: Q: "...sr/bin/rpm -q p": package proftpd is not installed
> R: yum install of desired packages ok ..
> R: yum erase of unwanted packages ok ..
> R: package sudo installed
> R: rpm_minion YES THIS ONE
> R:       Found '2' yum repo client definitions
> R:       Found yum_repos_d client definition for
> 'perzl_supplemental'
> R:       Found yum_repos_d client definition for 'perzl_org'
> R:       Serialized Data:
> '{"perzl_org":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_mirror/aix71
> <http://nimmsag_a/repos/perzl_mirror/aix71>"},"gpgcheck":{"value":"0"},"gpgkey":{"value":""},"id":{"value":"perzl.org
> <http://perzl.org>"},"name":{"value":"perzl.org_AIX_7.1"}},"perzl_supplemental":{"baseurl":{"value":"http://nimmsag_a/repos/perzl_supplemental/aix71
> <http://this.name>space):$(this.bundle)\..*","yum_repos_d");
> ```
>
> You have a files type promise section, and after the any::
> class you seem to be defining a list. Before that varibale
> definition you need to specify vars: type promise.
>
> I hope this helps.
>
> On Tue, Aug 22, 2017 at 9:35 AM, Xander Cage
> <christia...@itsv.at> wrote:
>
> i am tinkering with mr. andersons yum policy
> (https://github.com/nickanderson/cfengine-yum
> <https://github.com/nickanderson/cfengine-yum>) and of
> <http://perzl.org>"},
> <http://perzl.org>"},
> <http://perzl.org>"},
>                     "name": { "value":
> "perzl.org_AIX_7.1"},
>                     "baseurl": { "value":
> "http://nimmsag_a/repos/perzl_mirror/aix71
> <http://nimmsag_a/repos/perzl_mirror/aix71>"},
>                     "gpgcheck": { "value": "0"},
>                     "gpgkey": { "value": "" }
>                   }
>                 }');
>
> "perzl_supplemental_dev"
>         meta =>{"yum_repos_d"},
>         data =>parsejson('{
>                   "perzl_supplemental_dev": {
>                     "id": { "value":
> "perzl_supplemental_dev"},
>                     "name": { "value":
> "perzl_supplemental_dev"},
>                     "baseurl": { "value":
> "http://nimmsag_a/repos/perzl_supplemental_dev/aix71
> <http://nimmsag_a/repos/perzl_supplemental_dev/aix71>"},
>                     "gpgcheck": { "value": "0"},
>                     "gpgkey": { "value": "" }
>                   }
>                 }');
>
>
>    aix_7_2.DEVELOPMENT_REPO_ENABLED::
>
>
> "perzl-org"
>         meta =>{"yum_repos_d"},
>         data =>parsejson('{
>                   "perzl-org": {
>                     "id": { "value": "perzl.org
> <http://perzl.org>"},
>                     "name": { "value":
> "perzl.org_AIX_7.2"},
>                     "baseurl": { "value":
> "http://nimmsag_a/repos/perzl_mirror/aix72
> <http://nimmsag_a/repos/perzl_mirror/aix72>"},
>                     "gpgcheck": { "value": "0"},
>                     "gpgkey": { "value": "" }
>                   }
>                 }');
>
> "perzl_supplemental_dev"
>         meta =>{"yum_repos_d"},
>         data =>parsejson('{
>                   "perzl_supplemental_dev": {
>                     "id": { "value":
> "perzl_supplemental_dev"},
>                     "name": { "value":
> "perzl_supplemental_dev"},
>                     "baseurl": { "value":
> "http://nimmsag_a/repos/perzl_supplemental_dev/aix72
> <http://nimmsag_a/repos/perzl_supplemental_dev/aix72>"},
>                     "gpgcheck": { "value": "0"},
>                     "gpgkey": { "value": "" }
>                   }
>                 }');
>
>
>       aix_7_1::
>
> "perzl-org"
>         meta =>{"yum_repos_d"},
>         data =>parsejson('{
>                   "perzl-org": {
>                     "id": { "value": "perzl.org
> <http://perzl.org>"},
>                     "name": { "value":
> "perzl.org_AIX_7.1"},
>                     "baseurl": { "value":
> "http://nimmsag_a/repos/perzl_mirror/aix71
> <http://nimmsag_a/repos/perzl_mirror/aix71>"},
>                     "gpgcheck": { "value": "0"},
>                     "gpgkey": { "value": "" }
>                   }
>                 }');
>
> "perzl_supplemental"
>         meta =>{"yum_repos_d"},
>         data =>parsejson('{
>                   "perzl_supplemental": {
>                     "id": { "value": "perzl_supplemental"},
>                     "name": { "value":
> "perzl_supplemental"},
>                     "baseurl": { "value":
> "http://nimmsag_a/repos/perzl_supplemental/aix71
> <http://nimmsag_a/repos/perzl_supplemental/aix71>"},
>                     "gpgcheck": { "value": "0"},
>                     "gpgkey": { "value": "" }
>                   }
>                 }');
>
>
>
>
>    aix_7_2::
>
> "perzl-org"
>         meta =>{"yum_repos_d"},
>         data =>parsejson('{
>                   "perzl-org": {
>                     "id": { "value": "perzl.org
> <http://perzl.org>"},
>                     "name": { "value":
> "perzl.org_AIX_7.2"},
>                     "baseurl": { "value":
> "http://nimmsag_a/repos/perzl_mirror/aix72
> <http://this.name>space):$(this.bundle)\..*","yum_repos_d");
>
> # Now we merge them all together into a single data var
> "data"data =>parsejson('[]');
> "data"data =>mergedata(data,$(repo_defs));
>
> # These variables are only useful when debugging
>      DEBUG|DEBUG_yum_repository_definitions::
> "s_data"string=>format("%S",data);
> "repo_ids"slist =>getindices(data);
> "repo_def_count"int=>length(repo_ids);
> Entercode here...
> |
>
>
>
> --
> You received this message because you are subscribed to
> the Google Groups "help-cfengine" group.
> To unsubscribe from this group and stop receiving emails
> from it, send an email to help-cfengin...@googlegroups.com.
> To post to this group, send email to
> help-c...@googlegroups.com.
> Visit this group at
> https://groups.google.com/group/help-cfengine
> <https://groups.google.com/group/help-cfengine>.
> For more options, visit
> https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "help-cfengine" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to help-cfengin...@googlegroups.com
> <mailto:help-cfengin...@googlegroups.com>.
> To post to this group, send email to help-c...@googlegroups.com
> <mailto:help-c...@googlegroups.com>.
--
---
Bas van der Vlies
| Operations, Support & Development | SURFsara | Science Park 140 | 1098
XG Amsterdam
| T +31 (0) 20 800 1300 | bas.van...@surfsara.nl | www.surfsara.nl |


Reply all
Reply to author
Forward
0 new messages