mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
[PR #6972/d0f229f5 backport][stable-7] Add consul_role module from domant PR (#7282)
Add consul_role module from domant PR (#6972)
* Update as per PR comments
* Move common code to module_utils
* Break up long import line
* Fix pipeline errors
* Inital version of check_mode support
* Fix updating a role, add tests
* Fix line spacing
* Fix line indentation
* Add consul-role tests
* Fixes for role update
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update as per MR comments
* Update as per MR comments
* Fix documentation issues
* Add types for sub-options
* Allow setting of policy, service and node id fields by specifying a value, or leaving them unchanged by omitting them
* Fix typo in test
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Reset and force push to get rid of merge
* Corrected unit tests
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Add suboptions documentation for node and service identities
* Fix PEP errors from pipeline
* Fix pipeline errors.
* Fix more pipeline errors
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Fix line that is too long
* Not specifying a value for description during update now leaves existing value unchanged
* Fixes for pipeline errors
* Add test cases to verify handling description works
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0f229f5d8
)
Co-authored-by: Valerio Poggi <106782233+valeriopoggi@users.noreply.github.com>
This commit is contained in:
parent
eefdf5b58e
commit
edd4637b9f
4 changed files with 875 additions and 0 deletions
29
plugins/module_utils/consul.py
Normal file
29
plugins/module_utils/consul.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2022, Håkon Lerring
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
def get_consul_url(configuration):
|
||||
return '%s://%s:%s/v1' % (configuration.scheme,
|
||||
configuration.host, configuration.port)
|
||||
|
||||
|
||||
def get_auth_headers(configuration):
|
||||
if configuration.token is None:
|
||||
return {}
|
||||
else:
|
||||
return {'X-Consul-Token': configuration.token}
|
||||
|
||||
|
||||
class RequestError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def handle_consul_response_error(response):
|
||||
if 400 <= response.status_code < 600:
|
||||
raise RequestError('%d %s' % (response.status_code, response.content))
|
Loading…
Add table
Add a link
Reference in a new issue