From 860a1d6eff646a96b890ed8ecf44d185c3343c47 Mon Sep 17 00:00:00 2001 From: Webster Mudge Date: Mon, 7 Jul 2025 13:18:08 -0400 Subject: [PATCH] Rename service_role and service_role_info to role and role_info Signed-off-by: Webster Mudge --- meta/runtime.yml | 11 +++ plugins/modules/{service_role.py => role.py} | 26 +++--- .../{service_role_info.py => role_info.py} | 18 ++-- .../modules/service_role/test_service_role.py | 88 +++++++++---------- .../test_service_role_info.py | 22 ++--- 5 files changed, 88 insertions(+), 77 deletions(-) rename plugins/modules/{service_role.py => role.py} (98%) rename plugins/modules/{service_role_info.py => role_info.py} (96%) diff --git a/meta/runtime.yml b/meta/runtime.yml index 68f86588..570a1ffd 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -162,3 +162,14 @@ plugin_routing: deprecation: removal_version: "6.0.0" warning_text: Use M(cloudera.cluster.cm_resource). + modules: + service_role: + redirect: cloudera.cluster.role + deprecation: + removal_version: "5.0.0" + warning_text: Use M(cloudera.cluster.role). + service_role_info: + redirect: cloudera.cluster.role_info + deprecation: + removal_version: "5.0.0" + warning_text: Use M(cloudera.cluster.role_info). diff --git a/plugins/modules/service_role.py b/plugins/modules/role.py similarity index 98% rename from plugins/modules/service_role.py rename to plugins/modules/role.py index f719f3df..2069b48c 100644 --- a/plugins/modules/service_role.py +++ b/plugins/modules/role.py @@ -16,7 +16,7 @@ # limitations under the License. DOCUMENTATION = r""" -module: service_role +module: role short_description: Manage a service role in cluster description: - Manage a service role in a cluster. @@ -134,12 +134,12 @@ requirements: - cm-client seealso: - - module: cloudera.cluster.service_role_info + - module: cloudera.cluster.role_info """ EXAMPLES = r""" - name: Provision a service role - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" password: "S&peR4Ec*re" @@ -149,7 +149,7 @@ cluster_hostname: worker-01.cloudera.internal - name: Set a service role to maintenance mode (using role name) - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" password: "S&peR4Ec*re" @@ -159,7 +159,7 @@ maintenance: true - name: Update (append) tags to a service role - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" password: "S&peR4Ec*re" @@ -172,7 +172,7 @@ tag_two: value_two - name: Set (purge) tags to a service role - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" cluster: example-cluster @@ -184,7 +184,7 @@ purge: true - name: Remove all tags on a service role - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" password: "S&peR4Ec*re" @@ -196,7 +196,7 @@ purge: true - name: Start a service role - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" password: "S&peR4Ec*re" @@ -207,7 +207,7 @@ state: started - name: Force a restart to a service role - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" password: "S&peR4Ec*re" @@ -218,7 +218,7 @@ state: restarted - name: Remove a service role - cloudera.cluster.service_role: + cloudera.cluster.role: host: example.cloudera.com username: "jane_smith" password: "S&peR4Ec*re" @@ -389,9 +389,9 @@ ) -class ClusterServiceRole(ClouderaManagerMutableModule): +class Role(ClouderaManagerMutableModule): def __init__(self, module): - super(ClusterServiceRole, self).__init__(module) + super(Role, self).__init__(module) # Set the parameters self.cluster = self.get_param("cluster") @@ -729,7 +729,7 @@ def main(): supports_check_mode=True, ) - result = ClusterServiceRole(module) + result = Role(module) output = dict( changed=result.changed, diff --git a/plugins/modules/service_role_info.py b/plugins/modules/role_info.py similarity index 96% rename from plugins/modules/service_role_info.py rename to plugins/modules/role_info.py index 94162d94..6221612a 100644 --- a/plugins/modules/service_role_info.py +++ b/plugins/modules/role_info.py @@ -16,7 +16,7 @@ # limitations under the License. DOCUMENTATION = r""" -module: service_role_info +module: role_info short_description: Retrieve information about the service roles of cluster description: - Gather information about one or all service roles of a CDP cluster. @@ -85,12 +85,12 @@ requirements: - cm_client seealso: - - module: cloudera.cluster.service_role + - module: cloudera.cluster.role """ EXAMPLES = r""" - name: Gather details of the roles for the 'yarn' service - cloudera.cluster.service_role_info: + cloudera.cluster.role_info: host: "example.cloudera.host" username: "jane_person" password: "S&peR4Ec*re" @@ -98,7 +98,7 @@ service: yarn - name: Gather the details with additional healthcheck information for the roles in the 'ecs' service - cloudera.cluster.service_role_info: + cloudera.cluster.role_info: host: "example.cloudera.host" username: "jane_person" password: "S&peR4Ec*re" @@ -107,7 +107,7 @@ view: healthcheck - name: Gather details of the 'NODEMANAGER' roles for the 'yarn' service - cloudera.cluster.service_role_info: + cloudera.cluster.role_info: host: "example.cloudera.host" username: "jane_person" password: "S&peR4Ec*re" @@ -116,7 +116,7 @@ type: NODEMANAGER - name: Gather details of the roles for the 'yarn' service on a particular cluster host - cloudera.cluster.service_role_info: + cloudera.cluster.role_info: host: "example.cloudera.host" username: "jane_person" password: "S&peR4Ec*re" @@ -269,9 +269,9 @@ from cm_client.rest import ApiException -class ClusterServiceRoleInfo(ClouderaManagerModule): +class RoleInfo(ClouderaManagerModule): def __init__(self, module): - super(ClusterServiceRoleInfo, self).__init__(module) + super(RoleInfo, self).__init__(module) # Set the parameters self.cluster = self.get_param("cluster") @@ -367,7 +367,7 @@ def main(): supports_check_mode=True, ) - result = ClusterServiceRoleInfo(module) + result = RoleInfo(module) output = dict( changed=False, diff --git a/tests/unit/plugins/modules/service_role/test_service_role.py b/tests/unit/plugins/modules/service_role/test_service_role.py index 08749b03..748d03df 100644 --- a/tests/unit/plugins/modules/service_role/test_service_role.py +++ b/tests/unit/plugins/modules/service_role/test_service_role.py @@ -39,7 +39,7 @@ RoleCommandsResourceApi, ) -from ansible_collections.cloudera.cluster.plugins.modules import service_role +from ansible_collections.cloudera.cluster.plugins.modules import role from ansible_collections.cloudera.cluster.plugins.module_utils.cm_utils import ( wait_bulk_commands, ) @@ -161,7 +161,7 @@ def test_service_role_missing_required(self, conn, module_args): module_args(conn) with pytest.raises(AnsibleFailJson, match="cluster, service"): - service_role.main() + role.main() def test_service_role_missing_one_of(self, conn, module_args): module_args( @@ -173,7 +173,7 @@ def test_service_role_missing_one_of(self, conn, module_args): ) with pytest.raises(AnsibleFailJson, match="type, name"): - service_role.main() + role.main() def test_service_role_missing_required_by_type(self, conn, module_args): module_args( @@ -186,7 +186,7 @@ def test_service_role_missing_required_by_type(self, conn, module_args): ) with pytest.raises(AnsibleFailJson, match="cluster_hostname, cluster_host_id"): - service_role.main() + role.main() def test_service_role_missing_required_by_type_exclusives(self, conn, module_args): module_args( @@ -204,7 +204,7 @@ def test_service_role_missing_required_by_type_exclusives(self, conn, module_arg AnsibleFailJson, match="mutually exclusive: cluster_hostname\|cluster_host_id", ): - service_role.main() + role.main() class TestServiceRoleInvalidParams: @@ -220,7 +220,7 @@ def test_service_role_invalid_cluster(self, conn, module_args): ) with pytest.raises(AnsibleFailJson, match="Cluster does not exist"): - service_role.main() + role.main() def test_service_role_invalid_service( self, @@ -245,7 +245,7 @@ def test_service_role_invalid_service( ) with pytest.raises(AnsibleFailJson, match="Service does not exist"): - service_role.main() + role.main() def test_service_role_invalid_type( self, @@ -273,7 +273,7 @@ def test_service_role_invalid_type( AnsibleFailJson, match="Base role config group of type EXAMPLE not found in service", ): - service_role.main() + role.main() def test_service_role_invalid_host( self, @@ -298,7 +298,7 @@ def test_service_role_invalid_host( ) with pytest.raises(AnsibleFailJson, match="Host not found"): - service_role.main() + role.main() def test_service_role_invalid_role_name(self, conn, module_args, zookeeper): module_args( @@ -311,7 +311,7 @@ def test_service_role_invalid_role_name(self, conn, module_args, zookeeper): ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert not e.value.role @@ -351,7 +351,7 @@ def test_service_role_provision_hostname( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -391,7 +391,7 @@ def test_service_role_provision_host_id( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["host_id"] == hosts[0].host_id @@ -434,7 +434,7 @@ def test_service_role_provision_config( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -490,7 +490,7 @@ def test_service_role_provision_role_config_group( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -535,7 +535,7 @@ def test_service_role_provision_tags( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -577,7 +577,7 @@ def test_service_role_provision_enable_maintenance( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -618,7 +618,7 @@ def test_service_role_provision_state_start( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -658,7 +658,7 @@ def test_service_role_provision_state_stopped( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -698,7 +698,7 @@ def test_service_role_provision_state_restarted( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.role["type"] == "SERVER" assert e.value.role["hostname"] == hosts[0].hostname @@ -804,7 +804,7 @@ def test_service_role_existing_name( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["type"] == server_role.type @@ -830,7 +830,7 @@ def test_service_role_existing_hostname( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["type"] == server_role.type @@ -856,7 +856,7 @@ def test_service_role_existing_hostid( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["type"] == server_role.type @@ -882,7 +882,7 @@ def test_service_role_existing_enable_maintenance( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == server_role.type @@ -892,7 +892,7 @@ def test_service_role_existing_enable_maintenance( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["maintenance_mode"] == True @@ -919,7 +919,7 @@ def test_service_role_existing_config( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == updated_server_role_config.type @@ -930,7 +930,7 @@ def test_service_role_existing_config( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["config"]["minSessionTimeout"] == "5001" @@ -958,7 +958,7 @@ def test_service_role_existing_config_purge( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == updated_server_role_config.type @@ -969,7 +969,7 @@ def test_service_role_existing_config_purge( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert "minSessionTimeout" not in e.value.role["config"] @@ -995,7 +995,7 @@ def test_service_role_existing_rcg( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == server_role.type @@ -1005,7 +1005,7 @@ def test_service_role_existing_rcg( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["config"]["minSessionTimeout"] == "4501" @@ -1029,7 +1029,7 @@ def test_service_role_existing_rcg_base( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == updated_server_role_rcg.type @@ -1039,7 +1039,7 @@ def test_service_role_existing_rcg_base( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert "minSessionTimeout" not in e.value.role["config"] @@ -1065,7 +1065,7 @@ def test_service_role_existing_tags( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == updated_server_role_tags.type @@ -1076,7 +1076,7 @@ def test_service_role_existing_tags( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["tags"]["existing"] == "tag" @@ -1104,7 +1104,7 @@ def test_service_role_existing_tags_purge( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == updated_server_role_tags.type @@ -1115,7 +1115,7 @@ def test_service_role_existing_tags_purge( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert "existing" not in e.value.role["tags"] @@ -1139,7 +1139,7 @@ def test_service_role_existing_state_started( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == stopped_server_role.type @@ -1148,7 +1148,7 @@ def test_service_role_existing_state_started( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["role_state"] == ApiRoleState.STARTED @@ -1171,7 +1171,7 @@ def test_service_role_existing_state_stopped( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == server_role.type @@ -1180,7 +1180,7 @@ def test_service_role_existing_state_stopped( # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert e.value.role["role_state"] == ApiRoleState.STOPPED @@ -1203,7 +1203,7 @@ def test_service_role_existing_state_restarted( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["type"] == server_role.type @@ -1212,7 +1212,7 @@ def test_service_role_existing_state_restarted( # Idempotency (rather, 'restarted' is not idempotent) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert e.value.role["role_state"] == ApiRoleState.STARTED @@ -1235,14 +1235,14 @@ def test_service_role_existing_state_absent( ) with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == True assert not e.value.role # Idempotency with pytest.raises(AnsibleExitJson) as e: - service_role.main() + role.main() assert e.value.changed == False assert not e.value.role diff --git a/tests/unit/plugins/modules/service_role_info/test_service_role_info.py b/tests/unit/plugins/modules/service_role_info/test_service_role_info.py index b4a122de..71b902a0 100644 --- a/tests/unit/plugins/modules/service_role_info/test_service_role_info.py +++ b/tests/unit/plugins/modules/service_role_info/test_service_role_info.py @@ -30,7 +30,7 @@ ApiService, ) -from ansible_collections.cloudera.cluster.plugins.modules import service_role_info +from ansible_collections.cloudera.cluster.plugins.modules import role_info from ansible_collections.cloudera.cluster.plugins.module_utils.cluster_utils import ( get_cluster_hosts, ) @@ -129,7 +129,7 @@ def test_service_role_info_missing_required(conn, module_args): module_args({**conn}) with pytest.raises(AnsibleFailJson, match="cluster"): - service_role_info.main() + role_info.main() def test_service_role_info_missing_cluster(conn, module_args): @@ -141,7 +141,7 @@ def test_service_role_info_missing_cluster(conn, module_args): ) with pytest.raises(AnsibleFailJson, match="cluster"): - service_role_info.main() + role_info.main() def test_service_role_info_invalid_service(conn, module_args, zookeeper): @@ -154,7 +154,7 @@ def test_service_role_info_invalid_service(conn, module_args, zookeeper): ) with pytest.raises(AnsibleFailJson, match="Service 'BOOM' not found in cluster"): - service_role_info.main() + role_info.main() def test_service_role_info_invalid_cluster(conn, module_args, zookeeper): @@ -167,7 +167,7 @@ def test_service_role_info_invalid_cluster(conn, module_args, zookeeper): ) with pytest.raises(AnsibleFailJson, match="Cluster does not exist: BOOM"): - service_role_info.main() + role_info.main() def test_service_role_info_all(conn, module_args, cm_api_client, zookeeper): @@ -185,7 +185,7 @@ def test_service_role_info_all(conn, module_args, cm_api_client, zookeeper): ) with pytest.raises(AnsibleExitJson) as e: - service_role_info.main() + role_info.main() assert len(e.value.roles) == len(expected_roles) @@ -206,7 +206,7 @@ def test_service_role_info_all_full(conn, module_args, cm_api_client, zookeeper) ) with pytest.raises(AnsibleExitJson) as e: - service_role_info.main() + role_info.main() assert len(e.value.roles) == len(expected_roles) @@ -227,7 +227,7 @@ def test_service_role_info_by_name(conn, module_args, cm_api_client, zookeeper): ) with pytest.raises(AnsibleExitJson) as e: - service_role_info.main() + role_info.main() assert len(e.value.roles) == 1 assert e.value.roles[0]["name"] == expected_roles[0].name @@ -261,7 +261,7 @@ def test_service_role_info_by_type( ) with pytest.raises(AnsibleExitJson) as e: - service_role_info.main() + role_info.main() assert len(e.value.roles) == len(expected_roles) @@ -288,7 +288,7 @@ def test_service_role_info_by_hostname( ) with pytest.raises(AnsibleExitJson) as e: - service_role_info.main() + role_info.main() assert len(e.value.roles) == 1 assert e.value.roles[0]["host_id"] == expected_roles[0].host_ref.host_id @@ -317,7 +317,7 @@ def test_service_role_info_by_host_id( ) with pytest.raises(AnsibleExitJson) as e: - service_role_info.main() + role_info.main() assert len(e.value.roles) == 1 assert e.value.roles[0]["host_id"] == expected_roles[0].host_ref.host_id