X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=juju-charms%2Flayers%2Fansible-charm%2Factions%2Fansible-playbook;fp=juju-charms%2Flayers%2Fansible-charm%2Factions%2Fansible-playbook;h=6133ca5969a0227fe3dd0f7fbe2bb3ff481d3072;hb=5ac13c722414928d2c89ab6e507e63fdf8bc3d8c;hp=0000000000000000000000000000000000000000;hpb=33205b2d01d9991e01eff47d817afcf9fc4634dd;p=osm%2Fdevops.git diff --git a/juju-charms/layers/ansible-charm/actions/ansible-playbook b/juju-charms/layers/ansible-charm/actions/ansible-playbook new file mode 100755 index 00000000..6133ca59 --- /dev/null +++ b/juju-charms/layers/ansible-charm/actions/ansible-playbook @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# +# OSM devops/juju-charms - Ansible charm inside OSM devops +# +# Copyright 2017-2018 Universidad Carlos III de Madrid +# +# Licensed 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. +# + +import sys +sys.path.append('lib') + +from charms.reactive import main +from charms.reactive import set_state +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_state('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e))