summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Foster <fosterbseth@gmail.com>2024-01-16 20:37:21 +0100
committerSeth Foster <fosterseth@users.noreply.github.com>2024-02-02 16:37:41 +0100
commit69102cf26565ea6930a28965746831f3cfa08a69 (patch)
tree1730b8e56a3da4e530680bcda3467d820de4e1b6
parentMake canonical field default to False (diff)
downloadawx-69102cf26565ea6930a28965746831f3cfa08a69.tar.xz
awx-69102cf26565ea6930a28965746831f3cfa08a69.zip
Remove receptor_address module from collection
After removing CRUD from receptor addresses, we need to remove the module. - remove receptor_address module - Add listener_port to instance module - Add peers_from_control_nodes to instance module Signed-off-by: Seth Foster <fosterbseth@gmail.com>
-rw-r--r--awx_collection/meta/runtime.yml1
-rw-r--r--awx_collection/plugins/module_utils/controller_api.py2
-rw-r--r--awx_collection/plugins/modules/instance.py18
-rw-r--r--awx_collection/plugins/modules/receptor_address.py135
-rw-r--r--awx_collection/test/awx/test_completeness.py2
-rw-r--r--awx_collection/test/awx/test_instance.py11
-rw-r--r--awx_collection/tests/integration/targets/instance/tasks/main.yml34
7 files changed, 22 insertions, 181 deletions
diff --git a/awx_collection/meta/runtime.yml b/awx_collection/meta/runtime.yml
index 8ffc5bd122..18fa4b592e 100644
--- a/awx_collection/meta/runtime.yml
+++ b/awx_collection/meta/runtime.yml
@@ -34,7 +34,6 @@ action_groups:
- organization
- project
- project_update
- - receptor_address
- role
- schedule
- settings
diff --git a/awx_collection/plugins/module_utils/controller_api.py b/awx_collection/plugins/module_utils/controller_api.py
index 2c110a9572..166d43c49e 100644
--- a/awx_collection/plugins/module_utils/controller_api.py
+++ b/awx_collection/plugins/module_utils/controller_api.py
@@ -930,8 +930,6 @@ class ControllerAPIModule(ControllerModule):
item_name = existing_item['id']
elif item_type == 'instance':
item_name = existing_item['hostname']
- elif item_type == 'receptor_address':
- item_name = existing_item['address']
else:
item_name = existing_item['name']
item_id = existing_item['id']
diff --git a/awx_collection/plugins/modules/instance.py b/awx_collection/plugins/modules/instance.py
index 2efcdd6f5f..af7360687f 100644
--- a/awx_collection/plugins/modules/instance.py
+++ b/awx_collection/plugins/modules/instance.py
@@ -58,6 +58,11 @@ options:
- installed
required: False
type: str
+ listener_port:
+ description:
+ - Port that Receptor will listen for incoming connections on.
+ required: False
+ type: int
peers:
description:
- List of peers to connect outbound to. Only configurable for hop and execution nodes.
@@ -67,6 +72,11 @@ options:
required: False
type: list
elements: str
+ peers_from_control_nodes:
+ description:
+ - If enabled, control plane nodes will automatically peer to this node.
+ required: False
+ type: bool
extends_documentation_fragment: awx.awx.auth
'''
@@ -107,7 +117,9 @@ def main():
managed_by_policy=dict(type='bool'),
node_type=dict(type='str', choices=['execution', 'hop']),
node_state=dict(type='str', choices=['deprovisioning', 'installed']),
+ listener_port=dict(type='int'),
peers=dict(required=False, type='list', elements='str'),
+ peers_from_control_nodes=dict(required=False, type='bool'),
)
# Create a module for ourselves
@@ -120,7 +132,9 @@ def main():
managed_by_policy = module.params.get('managed_by_policy')
node_type = module.params.get('node_type')
node_state = module.params.get('node_state')
+ listener_port = module.params.get('listener_port')
peers = module.params.get('peers')
+ peers_from_control_nodes = module.params.get('peers_from_control_nodes')
# Attempt to look up an existing item based on the provided data
existing_item = module.get_one('instances', name_or_id=hostname)
@@ -147,8 +161,12 @@ def main():
new_fields['node_type'] = node_type
if node_state is not None:
new_fields['node_state'] = node_state
+ if listener_port is not None:
+ new_fields['listener_port'] = listener_port
if peers is not None:
new_fields['peers'] = peers_ids
+ if peers_from_control_nodes is not None:
+ new_fields['peers_from_control_nodes'] = peers_from_control_nodes
module.create_or_update_if_needed(
existing_item,
diff --git a/awx_collection/plugins/modules/receptor_address.py b/awx_collection/plugins/modules/receptor_address.py
deleted file mode 100644
index 5d43245c77..0000000000
--- a/awx_collection/plugins/modules/receptor_address.py
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/usr/bin/python
-# coding: utf-8 -*-
-
-
-# (c) 2023 Red Hat, Inc.
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: receptor_address
-author: "Seth Foster (@fosterseth)"
-version_added: "4.5.0"
-short_description: create, update, or destroy Automation Platform Controller receptor addresses.
-description:
- - Create, update, or destroy Automation Platform Controller receptor addresses. See
- U(https://www.ansible.com/tower) for an overview.
-options:
- address:
- description:
- - Routable address for this instance.
- required: True
- type: str
- instance:
- description:
- - ID or hostname of instance this address belongs to.
- required: True
- type: str
- peers_from_control_nodes:
- description:
- - If True, control plane cluster nodes should automatically peer to it.
- required: False
- type: bool
- port:
- description:
- - Port for the address.
- required: False
- type: int
- protocol:
- description:
- - Protocol to use when connecting.
- required: False
- type: str
- choices: [ 'tcp', 'ws', 'wss' ]
- websocket_path:
- description:
- - Websocket path.
- required: False
- type: str
- state:
- description:
- - Desired state of the resource.
- choices: ["present", "absent", "exists"]
- default: "present"
- type: str
-extends_documentation_fragment: awx.awx.auth
-'''
-
-EXAMPLES = '''
- - name: Create receptor address
- awx.awx.receptor_address:
- address: exec1addr
- instance: exec1.example.com
- peers_from_control_nodes: false
- port: 6791
- protocol: ws
- websocket_path: service
- state: present
- register: exec1addr
-'''
-
-from ..module_utils.controller_api import ControllerAPIModule
-
-
-def main():
- # Any additional arguments that are not fields of the item can be added here
- argument_spec = dict(
- address=dict(required=True, type='str'),
- instance=dict(required=True, type='str'),
- peers_from_control_nodes=dict(type='bool'),
- port=dict(type='int'),
- protocol=dict(type='str', choices=['tcp', 'ws', 'wss']),
- websocket_path=dict(type='str'),
- state=dict(choices=['present', 'absent', 'exists'], default='present'),
- )
-
- # Create a module for ourselves
- module = ControllerAPIModule(argument_spec=argument_spec)
-
- # Extract our parameters
- address = module.params.get('address')
- peers_from_control_nodes = module.params.get('peers_from_control_nodes')
- port = module.params.get('port')
- protocol = module.params.get('protocol', 'tcp')
- websocket_path = module.params.get('websocket_path')
- instance_name_or_id = module.params.get('instance')
- state = module.params.get('state')
-
- # Attempt to look up an existing instance
- receptor_address = module.get_one('receptor_addresses', allow_none=True, data=dict(address=address, protocol=protocol))
- if receptor_address:
- receptor_address['type'] = 'receptor_address'
-
- if receptor_address and state == 'absent':
- module.delete_if_needed(receptor_address)
-
- instance = module.get_one('instances', allow_none=False, name_or_id=instance_name_or_id)
-
- # Create the data that gets sent for create and update
- new_fields = {'instance': instance['id'], 'address': address}
- if port:
- new_fields['port'] = port
- if protocol:
- new_fields['protocol'] = protocol
- if peers_from_control_nodes:
- new_fields['peers_from_control_nodes'] = peers_from_control_nodes
- if websocket_path:
- new_fields['websocket_path'] = websocket_path
-
- module.create_or_update_if_needed(
- receptor_address,
- new_fields,
- endpoint='receptor_addresses',
- item_type='receptor_address',
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/awx_collection/test/awx/test_completeness.py b/awx_collection/test/awx/test_completeness.py
index b208f3cdb0..42d013df6c 100644
--- a/awx_collection/test/awx/test_completeness.py
+++ b/awx_collection/test/awx/test_completeness.py
@@ -248,8 +248,6 @@ def test_completeness(collection_import, request, admin_user, job_template, exec
singular_endpoint = '{0}'.format(endpoint)
if singular_endpoint.endswith('ies'):
singular_endpoint = singular_endpoint[:-3]
- elif singular_endpoint.endswith('ses'): # receptor_addresses
- singular_endpoint = singular_endpoint[:-2]
elif singular_endpoint != 'settings' and singular_endpoint.endswith('s'):
singular_endpoint = singular_endpoint[:-1]
module_name = '{0}'.format(singular_endpoint)
diff --git a/awx_collection/test/awx/test_instance.py b/awx_collection/test/awx/test_instance.py
index 1cef3220da..06d1fe94bd 100644
--- a/awx_collection/test/awx/test_instance.py
+++ b/awx_collection/test/awx/test_instance.py
@@ -13,7 +13,7 @@ def test_peers_adding_and_removing(run_module, admin_user):
with override_settings(IS_K8S=True):
result = run_module(
'instance',
- {'hostname': 'hopnode', 'node_type': 'hop', 'node_state': 'installed'},
+ {'hostname': 'hopnode', 'node_type': 'hop', 'node_state': 'installed', 'listener_port': 6789},
admin_user,
)
assert result['changed']
@@ -22,19 +22,12 @@ def test_peers_adding_and_removing(run_module, admin_user):
assert hop_node.node_type == 'hop'
- result = run_module(
- 'receptor_address',
- {'address': 'hopnodeaddr', 'instance': 'hopnode', 'port': 6789},
- admin_user,
- )
- assert result['changed']
-
address = hop_node.receptor_addresses.get(pk=result.get('id'))
assert address.port == 6789
result = run_module(
'instance',
- {'hostname': 'executionnode', 'node_type': 'execution', 'node_state': 'installed', 'peers': ['hopnodeaddr']},
+ {'hostname': 'executionnode', 'node_type': 'execution', 'node_state': 'installed', 'peers': ['hopnode']},
admin_user,
)
assert result['changed']
diff --git a/awx_collection/tests/integration/targets/instance/tasks/main.yml b/awx_collection/tests/integration/targets/instance/tasks/main.yml
index f97f80b9cb..045567b504 100644
--- a/awx_collection/tests/integration/targets/instance/tasks/main.yml
+++ b/awx_collection/tests/integration/targets/instance/tasks/main.yml
@@ -82,21 +82,6 @@
that:
- result is changed
- - name: Create address for hop node 1
- awx.awx.receptor_address:
- address: "{{ hostname1 }}addr"
- instance: "{{ hostname1 }}"
- peers_from_control_nodes: false
- port: 27199
- protocol: ws
- websocket_path: service
- state: present
- register: result
-
- - assert:
- that:
- - result is changed
-
- name: Create hop node 2
awx.awx.instance:
hostname: "{{ hostname2 }}"
@@ -108,29 +93,14 @@
that:
- result is changed
- - name: Create address for hop node 2
- awx.awx.receptor_address:
- address: "{{ hostname2 }}addr"
- instance: "{{ hostname2 }}"
- peers_from_control_nodes: false
- port: 27199
- protocol: ws
- websocket_path: service
- state: present
- register: result
-
- - assert:
- that:
- - result is changed
-
- name: Create execution node
awx.awx.instance:
hostname: "{{ hostname3 }}"
node_type: execution
node_state: installed
peers:
- - "{{ hostname1 }}addr"
- - "{{ hostname2 }}addr"
+ - "{{ hostname1 }}"
+ - "{{ hostname2 }}"
register: result
- assert: