Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,75 +32,75 @@ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
## Available Modules

### Job Worker Management
- **activate_job_worker**: Activate the job worker for an IAP system
- **activate_job_worker**: Activate the job worker for an Itential Platform system
```yaml
- name: Activate IAP job worker
- name: Activate Itential Platform job worker
itential.platform.activate_job_worker:
```

- **deactivate_job_worker**: Deactivate the job worker for an IAP system
- **deactivate_job_worker**: Deactivate the job worker for an Itential Platform system
```yaml
- name: Deactivate IAP job worker
- name: Deactivate Itential Platform job worker
itential.platform.deactivate_job_worker:
```

### Task Worker Management
- **activate_task_worker**: Activate the task worker for an IAP system
- **activate_task_worker**: Activate the task worker for an Itential Platform system
```yaml
- name: Activate IAP task worker
- name: Activate Itential Platform task worker
itential.platform.activate_task_worker:
```

- **deactivate_task_worker**: Deactivate the task worker for an IAP system
- **deactivate_task_worker**: Deactivate the task worker for an Itential Platform system
```yaml
- name: Deactivate IAP task worker
- name: Deactivate Itential Platform task worker
itential.platform.deactivate_task_worker:
```

### System Information
- **get_system_health**: Retrieve the health status of an IAP system
- **get_system_health**: Retrieve the health status of an Itential Platform system
```yaml
- name: Get IAP system health
- name: Get Itential Platform system health
itential.platform.get_system_health:
```

- **get_worker_status**: Get the current status of IAP workers
- **get_worker_status**: Get the current status of Itential Platform workers
```yaml
- name: Get IAP worker status
- name: Get Itential Platform worker status
itential.platform.get_worker_status:
```

### Job and Task Management
- **get_jobs**: Retrieve a list of jobs from an IAP system
- **get_jobs**: Retrieve a list of jobs from an Itential Platform system
```yaml
- name: Get IAP jobs
- name: Get Itential Platform jobs
itential.platform.get_jobs:
```

- **get_tasks**: Retrieve a list of tasks from an IAP system
- **get_tasks**: Retrieve a list of tasks from an Itential Platform system
```yaml
- name: Get IAP tasks
- name: Get Itential Platform tasks
itential.platform.get_tasks:
```

### System Administration
- **restart_adapter**: Restart a specific adapter in the IAP system
- **restart_adapter**: Restart a specific adapter in the Itential Platform system
```yaml
- name: Restart IAP adapter
- name: Restart Itential Platform adapter
itential.platform.restart_adapter:
adapter_name: "my-adapter"
```

- **restart_application**: Restart the IAP application
- **restart_application**: Restart the Itential Platform application
```yaml
- name: Restart IAP application
- name: Restart Itential Platform application
itential.platform.restart_application:
```

### Connection Parameters
Each module requires the following connection parameters which can be defined in your Ansible environment:
- `host`: The hostname or IP of the IAP instance
- `port`: The port number for the IAP API
- `host`: The hostname or IP of the Itential Platform instance
- `port`: The port number for the Itential Platform API
- `use_tls`: Whether to use HTTPS (default: true)
- `verify`: Whether to verify SSL certificates (default: true)
- `disable_warnings`: Whether to disable SSL warning messages (default: false)
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/activate_job_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Activates the IAP job worker. No parameters required.
# Activates the Itential Platform job worker. No parameters required.
# Example:
# - name: Activate job worker
# itential.platform.activate_job_worker:
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/activate_task_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Activates the IAP task worker. No parameters required.
# Activates the Itential Platform task worker. No parameters required.
# Example:
# - name: Activate task worker
# itential.platform.activate_task_worker:
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/deactivate_job_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Deactivates the IAP job worker. No parameters required.
# Deactivates the Itential Platform job worker. No parameters required.
# Example:
# - name: Deactivate job worker
# itential.platform.deactivate_job_worker:
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/deactivate_task_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Deactivates the IAP task worker. No parameters required.
# Deactivates the Itential Platform task worker. No parameters required.
# Example:
# - name: Deactivate task worker
# itential.platform.deactivate_task_worker:
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/get_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Retrieves list of jobs from IAP. No parameters required.
# Retrieves list of jobs from Itential Platform. No parameters required.
# Returns: List of job objects with their status and details.
# Example:
# - name: Get all jobs
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/get_system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Retrieves IAP system health status. No parameters required.
# Retrieves the Itential Platform system health status. No parameters required.
# Returns: System health information including component statuses.
# Example:
# - name: Get system health
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/get_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Retrieves list of tasks from IAP. Supports filtering via parameters.
# Retrieves list of tasks from Itential Platform. Supports filtering via parameters.
# Returns: List of task objects with their status and details.
# Example:
# - name: Get tasks by status
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/get_worker_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Retrieves status of all IAP workers. No parameters required.
# Retrieves status of all Itential Platform workers. No parameters required.
# Returns: Status information for job and task workers.
# Example:
# - name: Get worker status
Expand Down
4 changes: 2 additions & 2 deletions plugins/action/restart_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Restarts one or more IAP adapters.
# Restarts one or more Itential Platform adapters.
# Parameters:
# adapter_names: A single adapter name (str) or a list of adapter names (list).
#
Expand Down Expand Up @@ -34,7 +34,7 @@ class ActionModule(ActionBase):
_requires_connection = False

def run(self, tmp=None, task_vars=None):
"""Restart one or more IAP adapters by making API requests."""
"""Restart one or more Itential Platform adapters by making API requests."""

adapter_names = self._task.args.get("adapter_names")
if not adapter_names:
Expand Down
18 changes: 9 additions & 9 deletions plugins/action/restart_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

# Restarts one or more IAP applications.
# Restarts one or more Itential Platform applications.
# Parameters:
# application_names: A single application name (str) or a list of application names (list).
#
# Examples:
# - name: Restart a single application (string input)
# itential.platform.restart_application:
# application_names: "iap-core"
# itential.platform.restart_applications:
# application_names: OperationsManager
#
# - name: Restart a single application (list input)
# itential.platform.restart_application:
# itential.platform.restart_applications:
# application_names:
# - iap-core
# - OperationsManager
#
# - name: Restart multiple applications
# itential.platform.restart_application:
# itential.platform.restart_applications:
# application_names:
# - iap-core
# - OperationsManager
# - ag-manager

from ansible.plugins.action import ActionBase
Expand All @@ -34,7 +34,7 @@ class ActionModule(ActionBase):
_requires_connection = False

def run(self, tmp=None, task_vars=None):
"""Restart one or more IAP applications by making API requests."""
"""Restart one or more Itential Platform applications by making API requests."""

application_names = self._task.args.get("application_names")
if not application_names:
Expand All @@ -53,4 +53,4 @@ def run(self, tmp=None, task_vars=None):
response = make_request(task_vars, method, endpoint)
results.append(response)

return {"results": results} # Always return a list
return {"results": results}
37 changes: 17 additions & 20 deletions plugins/module_utils/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
type: str
required: true
vars:
- itential_host
- ansible_host

port:
description:
- The port used to connect to the remote host
type: int
vars:
- itential_port
- ansible_port
- iap_port
- platform_port
- platform_http_port
- platform_https_port

username:
description:
Expand All @@ -41,9 +40,8 @@
vars:
- itential_http_user
- itential_user
- ansible_user
- iap_username
- iap_user
- platform_username
- platform_user

password:
description:
Expand All @@ -52,60 +50,59 @@
vars:
- itential_http_password
- itential_password
- ansible_password
- iap_password
- iap_pass
- platform_password
- platform_pass

iap_auth_token:
platform_auth_token:
description:
- The authentication token to use for IAP requests (optional)
- The authentication token to use for Itential Platform requests (optional)
type: str
vars:
- iap_auth_token
- platform_auth_token

use_tls:
description:
- Enable or disable the use of TLS for the connection
type: bool
default: true
default: false
vars:
- itential_http_use_tls
- platform_https

headers:
description:
- The set of key/value pairs to include in the header on every request
type: dict
vars:
- intential_http_headers
- platform_http_headers

base_path:
description:
- The API base path to prepend for every request
type: str
vars:
- itential_http_base_path
- platform_http_base_path

auth_type:
description:
- The HTTP authorization type to use
type: str
choices: [ "basic", "token" ]
vars:
- itential_http_auth_type
- platform_http_auth_type

verify:
description:
- Enable or disable the validataion of certificates when using TLS
type: bool
default: true
vars:
- itential_http_verify
- platform_http_verify

disable_warnings:
description:
- Enable or disable warning messages
type: bool
default: false
vars:
- itential_http_disable_warnings
- platform_http_disable_warnings
"""
21 changes: 15 additions & 6 deletions plugins/module_utils/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

import json

from functools import partial
# This module provides a function to authenticate with the Itential Platform API.
# It handles:
# - Constructing a login request with the proper URL, headers, and JSON-encoded credentials.
# - Validating required properties (username and password) before sending the request.
# - Sending a POST request to the Itential Platform's `/login` endpoint using TLS or non-TLS
# based on the host object.
# - Handling exceptions, including missing credentials, connection issues, and unexpected
# HTTP responses.
# - Returning the authentication token or response text if the login is successful.
# - Logging request details (URL and payload type) for debugging purposes.
#
# The function `login()` is used by Ansible modules and utilities to retrieve authentication
# tokens for subsequent API requests.

import json
from ansible.errors import AnsibleError

from ansible_collections.itential.core.plugins.module_utils import display
from ansible_collections.itential.core.plugins.module_utils import hosts

from ansible_collections.itential.core.plugins.module_utils import http

def login(host):
Expand All @@ -32,6 +40,7 @@ def login(host):
url = http.make_url(host.host, "/login", port=host.port, use_tls=host.use_tls)

data = json.dumps({"user": user}).encode("utf-8")
display.v(f"Request URL: {url}")
display.v(type(data))

try:
Expand Down
Loading