|
| 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 |
0 commit comments