Created
January 30, 2013 00:24
-
-
Save thekuffs/4669437 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Include the instantiated macro here | |
include: | |
- pkg_repo.10gen | |
mongo-10gen-server: | |
pkg: | |
- installed | |
- require: | |
- file: 'pkg_repo.10gen' | |
mongod: | |
service: | |
- running | |
- enable: True | |
- watch: | |
- pkg: 'mongo-10gen-server' |
This file contains hidden or 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
# This is where the macro is instantiated | |
# We instantiate it here to make it easy to import into other SLS allow for extends | |
{% from "pkg_repo/yum.sls" import yum_repo with context %} | |
{{ yum_repo('10gen', '10gen Repository', 'http://downloads-distro.mongodb.org/repo/redhat/os/x86_64') }} |
This file contains hidden or 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
# the definition of the yum_repo macro, to be implemented by a repo we want to use | |
{% macro yum_repo(name, long_name, baseurl, key_source=None, gpgkey=None) -%} | |
{% if key_source %} | |
# if there is a key to download from the master, prepare a couple shortcuts | |
{% set local_key_path = '/etc/pki/rpm-gpg/RPM-GPG-KEY-' + name %} | |
{% set gpgkey = 'file://' + local_key_path %} | |
{% set gpgcheck = 1 %} | |
# The actual key file | |
'pkg_repo.key-{{ name }}': | |
file.managed: | |
- name: '{{ local_key_path }}' | |
- source: '{{ key_source }}' | |
- user: root | |
- group: root | |
- mode: 644 | |
# The command to import the key | |
'pkg_repo.import-key-{{ name }}': | |
cmd.wait: | |
- name: '/bin/rpm --import {{ local_key_path }}' | |
- watch: | |
- file: '{{ local_key_path }}' | |
{% elif gpgkey %} | |
{% set gpgcheck = 1 %} | |
{% else %} | |
{% set gpgcheck = 0 %} | |
{% endif %} | |
# The repo file | |
'pkg_repo.{{ name }}': | |
file.managed: | |
- name: '/etc/yum.repos.d/{{ name }}.repo' | |
- source: 'salt://pkg_repo/templates/yum_repo.jinja' | |
- user: root | |
- group: root | |
- mode: '0644' | |
- template: jinja | |
- context: | |
short_name: '{{ name }}' | |
long_name: '{{ long_name }}' | |
baseurl: '{{ baseurl }}' | |
gpgkey: '{{ gpgkey }}' | |
gpgcheck: {{ gpgcheck }} | |
{% if key_source %} | |
- require: | |
- file: 'pkg_repo.key-{{ name }}' | |
- cmd: 'pkg_repo.import-key-{{ name }}' | |
{% endif %} | |
{%- endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment