diff --git a/cdist/conf/type/__yum_repo/files/repo.template b/cdist/conf/type/__yum_repo/files/repo.template new file mode 100755 index 00000000..73ef00f2 --- /dev/null +++ b/cdist/conf/type/__yum_repo/files/repo.template @@ -0,0 +1,60 @@ +#!/bin/sh +set -u +cat << DONE +# Created by cdist ${__type##*/} +# Do not change. Changes will be overwritten. +# +[$repo_name] +DONE +# single value properties +single_value='name +metalink +mirrorlist +gpgcakey +exclude +includepkgs +failovermethod +timeout +http_caching +retries +throttle +bandwidth +sslcacert +sslverify +sslclientcert +sslclientkey +ssl_check_cert_permissions +metadata_expire +mirrorlist_expire +proxy +proxy_username +proxy_password +username +password +cost' +for key in $single_value; do + if [ -f "$__object/parameter/$key" ]; then + printf '%s=%s\n' "$key" "$(cat "$__object/parameter/$key")" + fi +done +# multi value properties +for key in baseurl gpgkey; do + if [ -f "$__object/parameter/$key" ]; then + printf '%s=' "$key" + prefix='' + while read line; do + printf '%s%s\n' "$prefix" "$line" + prefix=' ' + done < "$__object/parameter/$key" + fi +done +# boolean properties +for key in enabled gpgcheck repo_gpgcheck keepalive skip_if_unavailable; do + if [ -f "$__object/parameter/$key" ]; then + printf '%s=1\n' "$key" + fi +done +# special cases +if [ -f "$__object/parameter/disablegroups" ]; then + printf 'enablegroups=0\n' +fi diff --git a/cdist/conf/type/__yum_repo/man.text b/cdist/conf/type/__yum_repo/man.text new file mode 100644 index 00000000..7af95f6a --- /dev/null +++ b/cdist/conf/type/__yum_repo/man.text @@ -0,0 +1,91 @@ +cdist-type__yum_repo(7) +======================= +Steven Armstrong + + +NAME +---- +cdist-type__yum_repo - manage yum repositories + + +DESCRIPTION +----------- +For all undocumented parameters see yum.conf(5). + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent'. Defaults to 'present' +repositoryid:: + Defaults to __object_id. +name:: +baseurl:: + Can be specified multiple times. +metalink:: +mirrorlist:: +gpgkey:: + Can be specified multiple times. +gpgcakey:: +exclude:: +includepkgs:: +failovermethod:: +timeout:: +http_caching:: +retries:: +throttle:: +bandwidth:: +sslcacert:: +sslverify:: +sslclientcert:: +sslclientkey:: +ssl_check_cert_permissions:: +metadata_expire:: +mirrorlist_expire:: +proxy:: +proxy_username:: +proxy_password:: +username:: +password:: +cost:: + + +BOOLEAN PARAMETERS +------------------ +enabled:: +gpgcheck:: +repo_gpgcheck:: +disablegroups:: + ! enablegroups +keepalive:: +skip_if_unavailable:: + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__yum_repo epel \ + --name 'Extra Packages for Enterprise Linux 6 - $basearch' \ + --mirrorlist 'https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch' \ + --failovermethod priority \ + --enabled \ + --gpgcheck \ + --gpgkey https://fedoraproject.org/static/0608B895.txt +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__yum_repo/manifest b/cdist/conf/type/__yum_repo/manifest new file mode 100755 index 00000000..9bb63c3c --- /dev/null +++ b/cdist/conf/type/__yum_repo/manifest @@ -0,0 +1,40 @@ +#!/bin/sh +# +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +os=$(cat "$__global/explorer/os") +state="$(cat "$__object/parameter/state")" + +case "$os" in + centos) + repo_name="$__object_id" + export repo_name + repo_file="/etc/yum.repos.d/${repo_name}.repo" + "$__type/files/repo.template" | \ + __file "$repo_file" \ + --owner root --group root --mode 644 \ + --state "$state" \ + --source - + ;; + *) + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__yum_repo/notes b/cdist/conf/type/__yum_repo/notes new file mode 100644 index 00000000..67fa617b --- /dev/null +++ b/cdist/conf/type/__yum_repo/notes @@ -0,0 +1,3 @@ +https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Configuring_Yum_and_Yum_Repositories.html +https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/2/html/Getting_Started_Guide/sect-Configuring_Software_Repositories.html +http://docs.puppetlabs.com/references/latest/type.html#yumrepo diff --git a/cdist/conf/type/__yum_repo/parameter/boolean b/cdist/conf/type/__yum_repo/parameter/boolean new file mode 100644 index 00000000..8fccfa7c --- /dev/null +++ b/cdist/conf/type/__yum_repo/parameter/boolean @@ -0,0 +1,6 @@ +enabled +gpgcheck +repo_gpgcheck +disablegroups +keepalive +skip_if_unavailable diff --git a/cdist/conf/type/__yum_repo/parameter/default/state b/cdist/conf/type/__yum_repo/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__yum_repo/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__yum_repo/parameter/optional b/cdist/conf/type/__yum_repo/parameter/optional new file mode 100644 index 00000000..dc432f28 --- /dev/null +++ b/cdist/conf/type/__yum_repo/parameter/optional @@ -0,0 +1,26 @@ +bandwidth +cost +exclude +failovermethod +gpgcakey +http_caching +includepkgs +metadata_expire +mirrorlist +mirrorlist_expire +name +password +proxy +proxy_password +proxy_username +repositoryid +retries +sslcacert +ssl_check_cert_permissions +sslclientcert +sslclientkey +sslverify +state +throttle +timeout +username diff --git a/cdist/conf/type/__yum_repo/parameter/optional_multiple b/cdist/conf/type/__yum_repo/parameter/optional_multiple new file mode 100644 index 00000000..6467915b --- /dev/null +++ b/cdist/conf/type/__yum_repo/parameter/optional_multiple @@ -0,0 +1,2 @@ +baseurl +gpgkey