Skip to content

Commit a076995

Browse files
Merge branch 'main' into version2.10
2 parents 912d56c + f007f00 commit a076995

File tree

6 files changed

+604
-0
lines changed

6 files changed

+604
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ fmt:
22
autoflake plugins/modules/*.py
33
autoflake plugins/module_utils/*.py
44
autoflake --recursive tests/
5+
autoflake migrationtool/*py
56

67
black plugins/modules/*.py
78
black plugins/module_utils/*.py
89
black tests/
10+
black migrationtool/*.py
911

1012
isort plugins/modules/*.py
1113
isort plugins/module_utils/*.py
1214
isort tests/
15+
isort migrationtool/*.py
1316

1417
yamlfmt .
1518

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,62 @@ export NETSCALER_NITRO_AUTH_TOKEN=$(curl -X POST -H "Content-Type:application/js
157157
echo $echo $NETSCALER_NITRO_AUTH_TOKEN
158158
```
159159

160+
### Migration Tool
161+
162+
The collection includes a migration tool to help convert existing Ansible playbooks from the legacy `citrix.adc` collection to the new `netscaler.adc` collection format. This tool simplifies the transition from legacy automation to the updated collection.
163+
164+
#### Features
165+
166+
- **Module Mapping**: Automatically converts `citrix.adc` modules to `netscaler.adc` modules
167+
- **NITRO Request Conversion**: Transforms `citrix_adc_nitro_request` tasks to specific resource modules
168+
- **State Conversion**: Maps legacy operations (`add`, `update`, `delete`) to appropriate state values
169+
- **Credential Preservation**: Maintains authentication parameters and playbook structure
170+
- **YAML Structure Preservation**: Keeps task names, variables, and organization intact
171+
172+
#### Usage
173+
174+
```bash
175+
# Basic conversion
176+
python3 migrationtool/convert_yaml.py -i legacy_playbook.yaml -o migrated_playbook.yaml
177+
178+
# With verbose output
179+
python3 migrationtool/convert_yaml.py -i legacy_playbook.yaml -o migrated_playbook.yaml -v
180+
```
181+
182+
#### Example Conversion
183+
184+
**Before (Legacy citrix.adc):**
185+
```yaml
186+
- name: Configure LB vserver
187+
citrix_adc_nitro_request:
188+
nsip: "{{ nsip }}"
189+
nitro_user: "{{ nitro_user }}"
190+
nitro_pass: "{{ nitro_pass }}"
191+
operation: add
192+
resource: lbvserver
193+
name: my_lb_vserver
194+
attributes:
195+
servicetype: HTTP
196+
ipv46: 10.10.10.10
197+
port: 80
198+
```
199+
200+
**After (New netscaler.adc):**
201+
```yaml
202+
- name: Configure LB vserver
203+
netscaler.adc.lbvserver:
204+
nsip: "{{ nsip }}"
205+
nitro_user: "{{ nitro_user }}"
206+
nitro_pass: "{{ nitro_pass }}"
207+
state: present
208+
name: my_lb_vserver
209+
servicetype: HTTP
210+
ipv46: 10.10.10.10
211+
port: 80
212+
```
213+
214+
For detailed migration tool documentation, usage examples, and troubleshooting, refer to the [Migration Tool README](https://github.com/netscaler/ansible-collection-netscaleradc/blob/main/migrationtool/README.md).
215+
160216
### Invocation
161217

162218
The credentials of the netscaler can be provided either in the playbook by hardcoding or defining in a inventory.ini file.

migrationtool/README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# NetScaler ADC Ansible Collection Migration Tool
2+
3+
This tool helps migrate existing Ansible playbooks from the legacy `citrix.adc` collection to the new `netscaler.adc` collection format.
4+
5+
## Overview
6+
7+
The migration tool converts YAML playbooks that use:
8+
- Legacy `citrix.adc` modules
9+
- `citrix_adc_nitro_request` generic module
10+
11+
Into playbooks that use the new `netscaler.adc` collection modules.
12+
13+
## Features
14+
15+
- **Module Mapping**: Automatically maps legacy module names to new collection modules
16+
- **State Conversion**: Converts NITRO request operations to appropriate state values
17+
- **Credential Handling**: Preserves and converts authentication parameters
18+
- **YAML Structure Preservation**: Maintains playbook structure, variables, and task organization
19+
20+
## Usage
21+
22+
### Basic Usage
23+
24+
```bash
25+
python3 convert_yaml.py -i input_playbook.yaml -o output_playbook.yaml
26+
```
27+
28+
### Arguments
29+
30+
- `-i, --input`: (Required) Path to the input YAML playbook
31+
- `-o, --output`: (Optional) Path for the output file. Defaults to `output.yaml`
32+
- `-v, --verbose`: (Optional) Enable verbose mode
33+
34+
### Example
35+
36+
```bash
37+
python convert_yaml.py -i legacy_playbook.yml -o migrated_playbook.yml
38+
```
39+
40+
## Supported Conversions
41+
42+
### Legacy Module Mappings
43+
The tool uses `resource_map` to convert legacy module names to new collection modules:
44+
- `citrix.adc.<resource_name>``netscaler.adc.<resource_name>`
45+
- `<resource_name>``netscaler.adc.<resource_name>`
46+
- `citrix_adc_nitro_request``netscaler.adc.<resource_name>`
47+
48+
### NITRO Request Conversion
49+
Converts `citrix_adc_nitro_request` tasks to specific resource modules:
50+
51+
**Before:**
52+
```yaml
53+
- name: Configure LB vserver
54+
citrix_adc_nitro_request:
55+
nsip: "{{ nsip }}"
56+
nitro_user: "{{ nitro_user }}"
57+
nitro_pass: "{{ nitro_pass }}"
58+
operation: present
59+
resource: lbvserver
60+
name: my_lb_vserver
61+
attributes:
62+
servicetype: HTTP
63+
ipv46: 10.10.10.10
64+
port: 80
65+
```
66+
67+
**After:**
68+
```yaml
69+
- name: Configure LB vserver
70+
netscaler.adc.lbvserver:
71+
nsip: "{{ nsip }}"
72+
nitro_user: "{{ nitro_user }}"
73+
nitro_pass: "{{ nitro_pass }}"
74+
state: present
75+
name: my_lb_vserver
76+
servicetype: HTTP
77+
ipv46: 10.10.10.10
78+
port: 80
79+
```
80+
81+
Converts `citrix.adc.<resource_name>` to `netscaler.adc.<resource_name>`
82+
**Before:**
83+
```yaml
84+
---
85+
- name: create server
86+
delegate_to: localhost
87+
citrix_adc_nitro_request:
88+
operation: add
89+
resource: server
90+
name: test-server-1
91+
attributes:
92+
name: test-server-1
93+
ipaddress: 10.10.10.10
94+
```
95+
96+
**After:**
97+
```yaml
98+
- name: Configure LB vserver
99+
netscaler.adc.lbvserver:
100+
nsip: "{{ nsip }}"
101+
nitro_user: "{{ nitro_user }}"
102+
nitro_pass: "{{ nitro_pass }}"
103+
state: present
104+
name: my_lb_vserver
105+
servicetype: HTTP
106+
ipv46: 10.10.10.10
107+
port: 80
108+
```
109+
110+
### State Mapping
111+
- `add`, `update` → `present`
112+
- `delete` → `absent`
113+
- `action` → Uses the action value from the task
114+
115+
## Files
116+
- `convert_yaml.py`: Main conversion script
117+
- `resourcelist.py`: Contains `resource_map` and `state_map` mappings
118+
119+
## Requirements
120+
121+
- Python 3.x
122+
- PyYAML
123+
124+
## Installation
125+
126+
```bash
127+
pip install pyyaml
128+
```
129+
130+
## Input Format Support
131+
132+
The tool supports various YAML input formats:
133+
- Single playbook dictionary
134+
- List of tasks
135+
136+
## Output
137+
138+
The tool generates a properly formatted YAML playbook with:
139+
- Converted module names
140+
- Preserved task names and structure
141+
- Proper indentation and formatting
142+
143+
## Troubleshooting
144+
145+
### Common Issues
146+
147+
1. **Resource not found**: Check if the resource type exists in `resource_map`
148+
2. **Missing name field**: Ensure the original task has a `name` parameter for NITRO requests
149+
3. **Authentication errors**: Verify credential parameters are correctly set
150+
151+
### Debug Output
152+
153+
The tool provides console output showing:
154+
- Module mappings being applied
155+
- NITRO request processing details
156+
- Tasks being converted
157+
158+
## Contributing
159+
160+
To add support for new modules:
161+
1. Update `resource_map` in `resourcelist.py`
162+
2. Add appropriate state mappings if needed
163+
3. Test with sample playbooks

migrationtool/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)