Skip to content

Commit f007f00

Browse files
Merge pull request #545 from netscaler/migration_tool_NSNETAUTO-1024
Migration tool nsnetauto 1024
2 parents 62d96eb + c9350d8 commit f007f00

File tree

5 files changed

+376
-122
lines changed

5 files changed

+376
-122
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: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ python convert_yaml.py -i legacy_playbook.yml -o migrated_playbook.yml
4141

4242
### Legacy Module Mappings
4343
The tool uses `resource_map` to convert legacy module names to new collection modules:
44-
- `citrix.adc.lbvserver``netscaler.adc.lbvserver`
45-
- `lbvserver``netscaler.adc.lbvserver`
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>`
4647

4748
### NITRO Request Conversion
4849
Converts `citrix_adc_nitro_request` tasks to specific resource modules:
@@ -77,12 +78,38 @@ Converts `citrix_adc_nitro_request` tasks to specific resource modules:
7778
port: 80
7879
```
7980
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+
80110
### State Mapping
81-
- `add` → `present`
82-
- `update` → `present`
111+
- `add`, `update` → `present`
83112
- `delete` → `absent`
84-
- `present` → `present`
85-
- `absent` → `absent`
86113
- `action` → Uses the action value from the task
87114

88115
## Files
@@ -104,14 +131,12 @@ pip install pyyaml
104131

105132
The tool supports various YAML input formats:
106133
- Single playbook dictionary
107-
- List of plays
108-
- List of tasks (automatically wrapped in a play structure)
134+
- List of tasks
109135

110136
## Output
111137

112138
The tool generates a properly formatted YAML playbook with:
113139
- Converted module names
114-
- Updated authentication parameters
115140
- Preserved task names and structure
116141
- Proper indentation and formatting
117142

0 commit comments

Comments
 (0)