Ivan Berezovskiy | f28ee09 | 2019-02-12 17:16:30 +0400 | [diff] [blame^] | 1 | import logging |
| 2 | |
| 3 | logger = logging.getLogger(__name__) |
| 4 | |
| 5 | def __virtual__(): |
| 6 | ''' |
| 7 | Only load if jenkins_common module exist. |
| 8 | ''' |
| 9 | if 'jenkins_common.call_groovy_script' not in __salt__: |
| 10 | return ( |
| 11 | False, |
| 12 | 'The jenkins_location state module cannot be loaded: ' |
| 13 | 'jenkins_common not found') |
| 14 | return True |
| 15 | |
| 16 | |
| 17 | def config(name, url, email=''): |
| 18 | """ |
| 19 | Jenkins location configuration. This value is used to |
| 20 | let Jenkins know how to refer to itself. |
| 21 | |
| 22 | :url: Jenkins location url: |
| 23 | :email: Jenkins server email |
| 24 | :returns: salt-specified state dict |
| 25 | """ |
| 26 | |
| 27 | template = __salt__['jenkins_common.load_template']( |
| 28 | 'salt://jenkins/files/groovy/location.template', |
| 29 | __env__) |
| 30 | |
| 31 | return __salt__['jenkins_common.api_call'](name, template, |
| 32 | ['CHANGED', 'EXISTS'], |
| 33 | {'url': url, 'email': email}, |
| 34 | 'location config') |