forked from Normation/rudder-techniques
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
techniques/applications/yumPackageManagerRepositories/1.0/changelog
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- Nicolas CHARLES <nicolas.charles@normation.com> Wed Nov 25 12:00:00 CEST 2014 | ||
* Version 1.0 | ||
** Creation of technique to manage Yum repositories | ||
|
100 changes: 100 additions & 0 deletions
100
techniques/applications/yumPackageManagerRepositories/1.0/metadata.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<TECHNIQUE name="Package sources (Yum)"> | ||
<DESCRIPTION>This technique configures repositories for Yum package manager. | ||
|
||
Each repositories are identified by their repository id.</DESCRIPTION> | ||
|
||
<MULTIINSTANCE>true</MULTIINSTANCE> | ||
|
||
<COMPATIBLE> | ||
<AGENT version=">= 3.12.0">cfengine-community</AGENT> | ||
</COMPATIBLE> | ||
|
||
<BUNDLES> | ||
<NAME>yum_repositories_management_RudderUniqueID</NAME> | ||
</BUNDLES> | ||
|
||
<TMLS> | ||
<TML name="yum-repositories-management"/> | ||
</TMLS> | ||
|
||
<FILES> | ||
<FILE name="zypper-repo.tml"> | ||
<INCLUDED>false</INCLUDED> | ||
</FILE> | ||
</FILES> | ||
|
||
<TRACKINGVARIABLE> | ||
<SAMESIZEAS>YUM_REPO_ID</SAMESIZEAS> | ||
</TRACKINGVARIABLE> | ||
|
||
<SECTIONS> | ||
<SECTION name="Repositories" multivalued="true" component="true" componentKey="YUM_REPO_ID"> | ||
<INPUT> | ||
<NAME>YUM_REPO_ID</NAME> | ||
<DESCRIPTION>Repository id</DESCRIPTION> | ||
<LONGDESCRIPTION>The unique repository id, in [ ] in the repository configuration</LONGDESCRIPTION> | ||
</INPUT> | ||
<SELECT1> | ||
<NAME>YUM_REPO_ACTION</NAME> | ||
<DESCRIPTION>Add/modify or delete the repository</DESCRIPTION> | ||
<ITEM> | ||
<VALUE>add</VALUE> | ||
<LABEL>Add/modify</LABEL> | ||
</ITEM> | ||
<ITEM> | ||
<VALUE>delete</VALUE> | ||
<LABEL>Delete</LABEL> | ||
</ITEM> | ||
<CONSTRAINT> | ||
<DEFAULT>add</DEFAULT> | ||
</CONSTRAINT> | ||
</SELECT1> | ||
<INPUT> | ||
<NAME>YUM_REPO_NAME</NAME> | ||
<DESCRIPTION>Repository name</DESCRIPTION> | ||
</INPUT> | ||
<INPUT> | ||
<NAME>YUM_REPO_URL</NAME> | ||
<DESCRIPTION>Repository URL</DESCRIPTION> | ||
</INPUT> | ||
<SELECT1> | ||
<NAME>YUM_REPO_ENABLED</NAME> | ||
<DESCRIPTION>Repository activation status</DESCRIPTION> | ||
<LONGDESCRIPTION>Activate or deactive a specific repository</LONGDESCRIPTION> | ||
<ITEM> | ||
<VALUE>0</VALUE> | ||
<LABEL>Disabled</LABEL> | ||
</ITEM> | ||
<ITEM> | ||
<VALUE>1</VALUE> | ||
<LABEL>Enabled</LABEL> | ||
</ITEM> | ||
<CONSTRAINT> | ||
<DEFAULT>1</DEFAULT> | ||
</CONSTRAINT> | ||
</SELECT1> | ||
<SELECT1> | ||
<NAME>YUM_REP_GPG_CHECK</NAME> | ||
<DESCRIPTION>Activate GPG check</DESCRIPTION> | ||
<ITEM> | ||
<VALUE>0</VALUE> | ||
<LABEL>No</LABEL> | ||
</ITEM> | ||
<ITEM> | ||
<VALUE>1</VALUE> | ||
<LABEL>Yes</LABEL> | ||
</ITEM> | ||
<CONSTRAINT> | ||
<DEFAULT>1</DEFAULT> | ||
</CONSTRAINT> | ||
</SELECT1> | ||
<INPUT> | ||
<NAME>YUM_REPO_GPG_URI</NAME> | ||
<DESCRIPTION>Location of the GPG Key</DESCRIPTION> | ||
<CONSTRAINT> | ||
<MAYBEEMPTY>true</MAYBEEMPTY> | ||
</CONSTRAINT> | ||
</INPUT> | ||
</SECTION> | ||
</SECTIONS> | ||
</TECHNIQUE> |
75 changes: 75 additions & 0 deletions
75
techniques/applications/yumPackageManagerRepositories/1.0/yum-repositories-management.st
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
bundle agent yum_repositories_management_&RudderUniqueID& { | ||
|
||
vars: | ||
&YUM_REPO_ID:{repo_id |"repo_id[&i&]" string => "&repo_id&"; | ||
}& | ||
&YUM_REPO_NAME:{repo_name |"repo_name[&i&]" string => "&repo_name&"; | ||
}& | ||
&YUM_REPO_ACTION:{repo_action |"repo_action[&i&]" string => "&repo_action&"; | ||
}& | ||
|
||
&YUM_REPO_URL:{repo_url |"repo_url[&i&]" string => "&repo_url&"; | ||
}& | ||
&YUM_REPO_ENABLED:{repo_enabled |"repo_enabled[&i&]" string => "&repo_enabled&"; | ||
}& | ||
&YUM_REP_GPG_CHECK:{repo_gpg_check |"repo_gpg_check[&i&]" string => "&repo_gpg_check&"; | ||
}& | ||
&YUM_REPO_GPG_URI:{repo_gpg_uri |"repo_gpg_uri[&i&]" string => "&repo_gpg_uri&"; | ||
}& | ||
&TRACKINGKEY:{uuid |"trackingkey[&i&]" string => "&uuid&"; | ||
}& | ||
|
||
"index" slist => getindices("repo_id"); | ||
|
||
|
||
# Construct the identifier string : \[repo_id\] | ||
"grep_repo_id[${index}]" string => "\[${repo_id[${index}]}\]"; | ||
|
||
pass1:: | ||
"filename[${index}]" string => execresult("grep -rl '${grep_repo_id[${index}]}' /etc/yum.repos.d"); | ||
|
||
# override filename if repo is absent | ||
"filename[${index}]" string => "/etc/yum.repos.d/rudder-${repo_id[${index}]}.repo", | ||
if => "repo_entry_absent_${index}"; | ||
|
||
"canonified_filename[${index}]" string => canonify("${filename[${index}]}"); | ||
|
||
classes: | ||
"delete_repo_${index}" expression => strcmp("${repo_action$[${index}]}", "delete"); | ||
|
||
pass1:: | ||
"repo_entry_absent_${index}" expression => strcmp("${filename$[${index}]}", ""); | ||
|
||
|
||
any:: | ||
"pass3" expression => "pass2"; | ||
"pass2" expression => "pass1"; | ||
"pass1" expression => "any"; | ||
|
||
|
||
methods: | ||
pass3:: | ||
# create or enforce entries | ||
"set repo name ${index}" usebundle => file_key_value_present_in_ini_section("${filename[${index}]}", "${repo_id[${index}]}", "name", "${repo_name[${index}]}"), | ||
if => "!delete_repo_${index}"; | ||
"set repo url ${index}" usebundle => file_key_value_present_in_ini_section("${filename[${index}]}", "${repo_id[${index}]}", "url", "${repo_url[${index}]}"), | ||
if => "!delete_repo_${index}"; | ||
"set repo enabled ${index}" usebundle => file_key_value_present_in_ini_section("${filename[${index}]}", "${repo_id[${index}]}", "enabled", "${repo_enabled[${index}]}"), | ||
if => "!delete_repo_${index}"; | ||
"set repo gpgcheck ${index}" usebundle => file_key_value_present_in_ini_section("${filename[${index}]}", "${repo_id[${index}]}", "gpgcheck", "${repo_gpg_check[${index}]}"), | ||
if => "!delete_repo_${index}"; | ||
"set repo gpg uri ${index}" usebundle => file_key_value_present_in_ini_section("${filename[${index}]}", "${repo_id[${index}]}", "gpgkey", "${repo_gpg_uri[${index}]}"), | ||
if => "!delete_repo_${index}"; | ||
|
||
|
||
# report | ||
# Using old_class_prefix to avoid having to copy all classes | ||
"report for modification" usebundle => rudder_common_reports_generic_index("Package sources (Yum)", "file_key_value_present_in_ini_section_${canonified_filename[${index}]}", "${trackingkey[${index}]}", "Repositories", "${repo_id[${index}]}", "Setting repository ${repo_name[${index}]} with id ${repo_id[${index}]} ", "${index}"), | ||
if => "!delete_repo_${index}"; | ||
|
||
# Deletion of repo | ||
"delete repo ${index}" usebundle => file_absent("${filename[${index}]}"), | ||
if => "delete_repo_${index}"; | ||
"report for deletion" usebundle => rudder_common_reports_generic_index("Package sources (Yum)", "file_absent_${canonified_filename[${index}]}", "${trackingkey[${index}]}", "Repositories", "${repo_id[${index}]}", "Deleting repository with id ${repo_id[${index}]} ", "${index}"), | ||
if => "delete_repo_${index}"; | ||
} |