new type __yum_repo to manage yum repositories
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
702a07b2d1
commit
40e517f50c
8 changed files with 229 additions and 0 deletions
60
cdist/conf/type/__yum_repo/files/repo.template
Executable file
60
cdist/conf/type/__yum_repo/files/repo.template
Executable file
|
@ -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
|
91
cdist/conf/type/__yum_repo/man.text
Normal file
91
cdist/conf/type/__yum_repo/man.text
Normal file
|
@ -0,0 +1,91 @@
|
|||
cdist-type__yum_repo(7)
|
||||
=======================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
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).
|
40
cdist/conf/type/__yum_repo/manifest
Executable file
40
cdist/conf/type/__yum_repo/manifest
Executable file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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
|
3
cdist/conf/type/__yum_repo/notes
Normal file
3
cdist/conf/type/__yum_repo/notes
Normal file
|
@ -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
|
6
cdist/conf/type/__yum_repo/parameter/boolean
Normal file
6
cdist/conf/type/__yum_repo/parameter/boolean
Normal file
|
@ -0,0 +1,6 @@
|
|||
enabled
|
||||
gpgcheck
|
||||
repo_gpgcheck
|
||||
disablegroups
|
||||
keepalive
|
||||
skip_if_unavailable
|
1
cdist/conf/type/__yum_repo/parameter/default/state
Normal file
1
cdist/conf/type/__yum_repo/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
|||
present
|
26
cdist/conf/type/__yum_repo/parameter/optional
Normal file
26
cdist/conf/type/__yum_repo/parameter/optional
Normal file
|
@ -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
|
2
cdist/conf/type/__yum_repo/parameter/optional_multiple
Normal file
2
cdist/conf/type/__yum_repo/parameter/optional_multiple
Normal file
|
@ -0,0 +1,2 @@
|
|||
baseurl
|
||||
gpgkey
|
Loading…
Reference in a new issue