Permalink
Please sign in to comment.
Showing
with
172 additions
and 0 deletions.
- +60 −0 .gitignore
- +30 −0 README.md
- +7 −0 config.yaml
- +15 −0 copyright
- +1 −0 layer.yaml
- +5 −0 metadata.yaml
- +53 −0 reactive/puppet.py
- +1 −0 wheelhouse.txt
60
.gitignore
| @@ -0,0 +1,60 @@ | ||
| +#### joe made this: http://goel.io/joe | ||
| + | ||
| +#####=== Python ===##### | ||
| + | ||
| +# Byte-compiled / optimized / DLL files | ||
| +__pycache__/ | ||
| +*.py[cod] | ||
| + | ||
| +# C extensions | ||
| +*.so | ||
| + | ||
| +# Distribution / packaging | ||
| +.Python | ||
| +env/ | ||
| +build/ | ||
| +develop-eggs/ | ||
| +dist/ | ||
| +downloads/ | ||
| +eggs/ | ||
| +lib64/ | ||
| +parts/ | ||
| +sdist/ | ||
| +var/ | ||
| +*.egg-info/ | ||
| +.installed.cfg | ||
| +*.egg | ||
| + | ||
| +# PyInstaller | ||
| +# Usually these files are written by a python script from a template | ||
| +# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
| +*.manifest | ||
| +*.spec | ||
| + | ||
| +# Installer logs | ||
| +pip-log.txt | ||
| +pip-delete-this-directory.txt | ||
| + | ||
| +# Unit test / coverage reports | ||
| +htmlcov/ | ||
| +.tox/ | ||
| +.coverage | ||
| +.cache | ||
| +nosetests.xml | ||
| +coverage.xml | ||
| + | ||
| +# Translations | ||
| +*.mo | ||
| +*.pot | ||
| + | ||
| +# Django stuff: | ||
| +*.log | ||
| + | ||
| +# Sphinx documentation | ||
| +docs/_build/ | ||
| + | ||
| +# PyBuilder | ||
| +target/ | ||
| + | ||
| +deps | ||
| +trusty |
30
README.md
| @@ -0,0 +1,30 @@ | ||
| +# layer-puppet | ||
| +> Juju charms.reactive layer for Puppet. | ||
| + The idea is shamelessly taken from battlemidget/juju-layer-node | ||
| + | ||
| +# emitters | ||
| + | ||
| +**puppet.available** - This state is automatically emitted once Puppet packages were | ||
| +installed. Rely on this state to perform an `puppet apply` deployment. | ||
| + | ||
| +# api | ||
| + | ||
| +The layer doesn't provide any special APIs | ||
| + | ||
| +# license | ||
| + | ||
| +Licensed to the Apache Software Foundation (ASF) under one | ||
| +or more contributor license agreements. See the NOTICE file | ||
| +distributed with this work for additional information | ||
| +regarding copyright ownership. The ASF licenses this file | ||
| +to you under the Apache License, Version 2.0 (the | ||
| +"License"); you may not use this file except in compliance | ||
| +with the License. You may obtain a copy of the License at | ||
| + | ||
| + http://www.apache.org/licenses/LICENSE-2.0 | ||
| + | ||
| +Unless required by applicable law or agreed to in writing, software | ||
| +distributed under the License is distributed on an "AS IS" BASIS, | ||
| +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| +See the License for the specific language governing permissions and | ||
| +limitations under the License. |
| @@ -0,0 +1,7 @@ | ||
| +options: | ||
| + install_sources: | | ||
| + - 'http://apt.puppetlabs.com trusty main' | ||
| + - 'http://apt.puppetlabs.com trusty dependencies' | ||
| + install_keys: | | ||
| + - '4BD6EC30' | ||
| + - '4BD6EC30' |
15
copyright
| @@ -0,0 +1,15 @@ | ||
| +Licensed to the Apache Software Foundation (ASF) under one | ||
| +or more contributor license agreements. See the NOTICE file | ||
| +distributed with this work for additional information | ||
| +regarding copyright ownership. The ASF licenses this file | ||
| +to you under the Apache License, Version 2.0 (the | ||
| +"License"); you may not use this file except in compliance | ||
| +with the License. You may obtain a copy of the License at | ||
| + | ||
| + http://www.apache.org/licenses/LICENSE-2.0 | ||
| + | ||
| +Unless required by applicable law or agreed to in writing, software | ||
| +distributed under the License is distributed on an "AS IS" BASIS, | ||
| +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| +See the License for the specific language governing permissions and | ||
| +limitations under the License. |
| @@ -0,0 +1 @@ | ||
| +includes: ['layer:basic', 'layer:apt'] |
| @@ -0,0 +1,5 @@ | ||
| +name: puppet | ||
| +summary: Latest stable puppet & hiera binaries for trusty | ||
| +description: | | ||
| + Layer delivers latest stable puppet and hiera (1.3.4) packages for trusty | ||
| + fixing YAML parsing bugs in hiera |
| @@ -0,0 +1,53 @@ | ||
| +from charms.reactive import ( | ||
| + hook, | ||
| + set_state, | ||
| + remove_state, | ||
| + main, | ||
| + when_not, | ||
| + when, | ||
| +) | ||
| + | ||
| +from charmhelpers.core import ( | ||
| + hookenv, | ||
| + unitdata, | ||
| +) | ||
| + | ||
| +from charms import apt | ||
| + | ||
| + | ||
| +config = hookenv.config() | ||
| +kv = unitdata.kv() | ||
| + | ||
| + | ||
| +@when_not('puppet.available') | ||
| +def install_puppet(): | ||
| + """ Installs latest Puppet & hiera packages | ||
| + | ||
| + Emits: | ||
| + puppet.available: Emitted once the runtime has been installed | ||
| + """ | ||
| + kv.set('puppet.url', config.get('install_sources')) | ||
| + kv.set('puppet.key', config.get('install_keys')) | ||
| + | ||
| + apt.queue_install(['puppet']) | ||
| + | ||
| + | ||
| +@when('apt.installed.puppet') | ||
| +@when_not('puppet.available') | ||
| +def puppet_id_set(): | ||
| + hookenv.status_set('active', 'Puppet is installed') | ||
| + set_state('puppet.available') | ||
| + | ||
| + | ||
| +@hook('config-changed') | ||
| +def version_check(): | ||
| + url = config.get('install_sources') | ||
| + key = config.get('install_keys') | ||
| + | ||
| + if url != kv.get('puppet.url') or key != kv.get('puppet.key'): | ||
| + apt.purge(['puppet']) | ||
| + remove_state('puppet.available') | ||
| + | ||
| + | ||
| +if __name__ == "__main__": | ||
| + main() |
| @@ -0,0 +1 @@ | ||
| +shell |
0 comments on commit
59bdb70