Skip to content

Commit f317135

Browse files
authored
Merge pull request #35 from cisco-en-programmability/cedge_adoption
Cedge adoption
2 parents 70d4242 + a0fc127 commit f317135

File tree

10 files changed

+337
-2
lines changed

10 files changed

+337
-2
lines changed

.ansible-lint

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ exclude_paths:
2727
verbosity: 1
2828

2929
# # Mock modules or roles in order to pass ansible-playbook --syntax-check
30-
# mock_modules:
30+
mock_modules:
31+
- amazon.aws.ec2_instance_info
32+
- amazon.aws.ec2_eip_info
33+
- azure.azcollection.azure_rm_publicipaddress_info
34+
- azure.azcollection.azure_rm_virtualmachine_info
3135
# - zuul_return
3236
# # note the foo.bar is invalid as being neither a module or a collection
3337
# - fake_namespace.fake_collection.fake_module

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace: cisco
22
name: sdwan_deployment
3-
version: 0.3.3
3+
version: 0.3.4
44
readme: README.md
55
authors:
66
- Arkadiusz Cichon <acichon@cisco.com>

roles/aws_device_params/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Ansible Role: aws_device_params
2+
3+
The `aws_device_params` Ansible role reads params from cEdge devices deployed on AWS, so that they can be used through other roles.
4+
5+
## Role Description
6+
7+
The `aws_device_params` role generates deployment facts for already deployed cEdge devices. For each cEdge deployment facts contain information about its:
8+
- `hostname`
9+
- `admin_username`
10+
- `admin_password`
11+
- `mgmt_public_ip`
12+
- `transport_public_ip`
13+
- `service_interfaces`
14+
Additionally the role sets the `manager_authentication` variable, which can be used for logging to vManage in other roles.
15+
16+
## Requirements
17+
18+
- The `cisco.sdwan_deployment` collection installed.
19+
- Ansible 2.16 or higher.
20+
- Ansible AWS modules (`amazon.aws` collection) installed.
21+
- AWS CLI configured with the appropriate permissions to create and manage AWS resources.
22+
23+
## Dependencies
24+
25+
There are no external role dependencies. Only `cisco.sdwan_deployment` collection is required.
26+
27+
### Required Variables
28+
29+
- `aws_tag_creator`: Tag for identifying the creator of AWS resources.
30+
- `aws_region`: AWS region to host the resources.
31+
- `admin_password`: The admin password for virtual machine access.
32+
33+
## Example Playbook
34+
35+
Including an example of how to use your role (for instance, with variables passed in as parameters):
36+
37+
```yaml
38+
- name: Read deployed cEdge parameters
39+
hosts: localhost
40+
gather_facts: false
41+
vars:
42+
aws_region: "us-east-1"
43+
aws_tag_creator: "tag-creator"
44+
admin_password: "password" # pragma: allowlist secret
45+
roles:
46+
- cisco.sdwan_deployment.aws_device_params
47+
```
48+
49+
## License
50+
51+
"GPL-3.0-only"
52+
53+
## Author Information
54+
55+
This role was created by Przemyslaw Susko <sprzemys@cisco.com>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024 Cisco Systems, Inc. and its affiliates
2+
3+
---
4+
5+
galaxy_info:
6+
author: Przemyslaw Susko <sprzemys@cisco.com>
7+
description: Deploy Cisco SD-WAN cEdges (C8000V) on AWS
8+
license: GPL-3.0-or-later
9+
min_ansible_version: "2.16.6"
10+
11+
galaxy_tags:
12+
- cisco
13+
- sdwan
14+
- catalystwan
15+
- networking
16+
17+
dependencies: []
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024 Cisco Systems, Inc. and its affiliates
2+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
3+
4+
---
5+
6+
- name: Get EIPs associated with the cEdge instances
7+
amazon.aws.ec2_eip_info:
8+
region: "{{ aws_region }}"
9+
filters:
10+
"tag:Creator": "{{ aws_tag_creator }}"
11+
tag:Machine: "*{{ hostname }}*"
12+
register: eip_info
13+
14+
- name: Extract management public IP
15+
ansible.builtin.set_fact:
16+
mgmt_public_ip: "{{ (eip_info.addresses | selectattr('tags.VPN', 'equalto', '512') | map(attribute='public_ip') | first) | default(None) }}"
17+
transport_public_ip: "{{ (eip_info.addresses | selectattr('tags.VPN', 'equalto', '0') | map(attribute='public_ip') | first) | default(None) }}"
18+
19+
- name: Set service_interfaces fact
20+
ansible.builtin.set_fact:
21+
service_interfaces: []
22+
last_index: 2
23+
24+
- name: Append to service_interfaces
25+
ansible.builtin.set_fact:
26+
service_interfaces: "{{ service_interfaces + [{'addr': eip.private_ip_address, 'index': last_index}] }}"
27+
last_index: "{{ last_index | int + 1 }}"
28+
loop: "{{ eip_info.addresses }}"
29+
loop_control:
30+
loop_var: eip
31+
when:
32+
- eip.tags.VPN != '512'
33+
- eip.tags.VPN != '0'
34+
35+
- name: Set instance fact
36+
ansible.builtin.set_fact:
37+
instance:
38+
hostname: "{{ hostname }}"
39+
admin_username: "admin"
40+
admin_password: "{{ admin_password }}"
41+
mgmt_public_ip: "{{ mgmt_public_ip }}"
42+
transport_public_ip: "{{ transport_public_ip }}"
43+
service_interfaces: "{{ service_interfaces }}"
44+
45+
- name: Update deployment facts
46+
ansible.builtin.set_fact:
47+
deployment_facts:
48+
deployed_edge_instances: "{{ deployment_facts.deployed_edge_instances + [instance] }}"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2024 Cisco Systems, Inc. and its affiliates
2+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
3+
4+
---
5+
6+
- name: Gather network resources information
7+
ansible.builtin.include_role:
8+
name: cisco.sdwan_deployment.aws_network_infrastructure
9+
tasks_from: aws_gather_network_resources.yml
10+
11+
- name: Gather information about EC2 instances with 'cedge' in their name
12+
amazon.aws.ec2_instance_info:
13+
region: "{{ aws_region }}"
14+
filters:
15+
"tag:Creator": "{{ aws_tag_creator }}"
16+
"tag:Name": "*vManage*"
17+
register: vmanage_ec2_info
18+
19+
- name: Get EIPs associated with the vManage instances
20+
amazon.aws.ec2_eip_info:
21+
region: "{{ aws_region }}"
22+
filters:
23+
"tag:Creator": "{{ aws_tag_creator }}"
24+
tag:Machine: "*{{ vmanage_ec2_info.instances | map(attribute='tags.Name') | list | first }}*"
25+
register: vmanage_eip_info
26+
27+
- name: Set manager authentication fact
28+
ansible.builtin.set_fact:
29+
manager_authentication:
30+
url: "{{ vmanage_eip_info.addresses | selectattr('tags.VPN', 'equalto', '512') | map(attribute='public_ip') | first }}"
31+
username: "admin"
32+
password: "{{ admin_password }}"
33+
34+
- name: Define deployment facts
35+
ansible.builtin.set_fact:
36+
deployment_facts:
37+
deployed_edge_instances: []
38+
39+
- name: Gather information about EC2 instances with 'cedge' in their name
40+
amazon.aws.ec2_instance_info:
41+
region: "{{ aws_region }}"
42+
filters:
43+
"tag:Creator": "{{ aws_tag_creator }}"
44+
"tag:Name": "*cedge*"
45+
register: cedge_ec2_info
46+
47+
- name: Get params for cEdge
48+
ansible.builtin.include_tasks: aws_cedge_ec2_instance.yml
49+
vars:
50+
hostname: "{{ host }}"
51+
loop: "{{ cedge_ec2_info.instances | map(attribute='tags.Name') | list }}"
52+
loop_control:
53+
loop_var: host
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
_# Ansible Role: azure_device_params
2+
3+
The `azure_device_params` Ansible role reads params from cEdge devices deployed on Azure, so that they can be used through other roles.
4+
5+
## Role Description
6+
7+
The `azure_device_params` role generates deployment facts for already deployed cEdge devices. For each cEdge deployment facts contain information about its:
8+
- `hostname`
9+
- `admin_username`
10+
- `admin_password`
11+
- `mgmt_public_ip`
12+
- `transport_public_ip`
13+
- `service_interfaces`
14+
Additionally the role sets the `manager_authentication` variable, which can be used for logging to vManage in other roles.
15+
16+
## Requirements
17+
18+
- The `cisco.sdwan_deployment` collection installed.
19+
- Ansible 2.16 or higher.
20+
- Ansible Azure modules (`azure.azcollection` collection) installed.
21+
- Azure CLI configured with the necessary permissions to manage Azure resources.
22+
23+
## Dependencies
24+
25+
There are no external role dependencies. Only `cisco.sdwan_deployment` collection is required.
26+
27+
### Required Variables
28+
29+
- `admin_password`: The admin password for virtual machine access.
30+
- `az_resource_group`: The name of the Azure resource group for the deployment.
31+
32+
## Example Playbook
33+
34+
Including an example of how to use your role (for instance, with variables passed in as parameters):
35+
36+
```yaml
37+
- name: Read deployed cEdge parameters
38+
hosts: localhost
39+
gather_facts: false
40+
vars:
41+
az_resource_group: "resource-group"
42+
admin_password: "password" # pragma: allowlist secret
43+
roles:
44+
- cisco.sdwan_deployment.azure_device_params
45+
```
46+
47+
## License
48+
49+
"GPL-3.0-only"
50+
51+
## Author Information
52+
53+
This role was created by Przemyslaw Susko <sprzemys@cisco.com>_
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024 Cisco Systems, Inc. and its affiliates
2+
3+
---
4+
5+
galaxy_info:
6+
author: Przemyslaw Susko <sprzemys@cisco.com>
7+
description: Deploy Cisco SD-WAN cEdges (C8000V) on AWS
8+
license: GPL-3.0-or-later
9+
min_ansible_version: "2.16.6"
10+
11+
galaxy_tags:
12+
- cisco
13+
- sdwan
14+
- catalystwan
15+
- networking
16+
17+
dependencies: []
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2024 Cisco Systems, Inc. and its affiliates
2+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
3+
4+
---
5+
6+
- name: Set mgmt and transport IP address facts
7+
ansible.builtin.set_fact:
8+
mgmt_public_ip: "{{ (public_ips | selectattr('tags.type', 'equalto', 'mgmt') | list | first).ip_address }}"
9+
transport_public_ip: "{{ (public_ips | selectattr('tags.type', 'equalto', 'transport') | list | first).ip_address }}"
10+
11+
- name: Get service NICs
12+
azure.azcollection.azure_rm_networkinterface_info:
13+
resource_group: "{{ az_resource_group }}"
14+
tags:
15+
- type:service
16+
register: service_nic_info
17+
18+
- name: Set helper facts
19+
ansible.builtin.set_fact:
20+
service_interfaces: []
21+
last_index: 2
22+
cedge_service_nic_info: "{{ service_nic_info.networkinterfaces | selectattr('tags.Name', 'search', hostname) | list }}"
23+
24+
- name: Append to service_interfaces fact
25+
ansible.builtin.set_fact:
26+
service_interfaces: "{{ service_interfaces + [{'addr': item.ip_configurations[0].private_ip_address, 'index': last_index}] }}"
27+
loop: "{{ cedge_service_nic_info }}"
28+
29+
- name: Set instance fact
30+
ansible.builtin.set_fact:
31+
instance:
32+
hostname: "{{ hostname }}"
33+
admin_username: "admin"
34+
admin_password: "{{ admin_password }}"
35+
mgmt_public_ip: "{{ mgmt_public_ip }}"
36+
transport_public_ip: "{{ transport_public_ip }}"
37+
service_interfaces: "{{ service_interfaces }}"
38+
39+
- name: Update deployment facts
40+
ansible.builtin.set_fact:
41+
deployment_facts:
42+
deployed_edge_instances: "{{ deployment_facts.deployed_edge_instances + [instance] }}"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2024 Cisco Systems, Inc. and its affiliates
2+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
3+
4+
---
5+
6+
- name: Verify if user session with Azure is active
7+
ansible.builtin.include_role:
8+
name: common
9+
tasks_from: az_user_session_probe
10+
11+
- name: Gather public IP addresses
12+
azure.azcollection.azure_rm_publicipaddress_info:
13+
resource_group: "{{ az_resource_group }}"
14+
register: public_ip_info
15+
16+
- name: Set manager authentication fact
17+
ansible.builtin.set_fact:
18+
manager_authentication:
19+
url: "{{ public_ip_info.publicipaddresses |
20+
selectattr('tags.Machine', 'search', 'vManage') |
21+
selectattr('tags.type', 'equalto', 'mgmt') |
22+
map(attribute='ip_address') |
23+
list | first }}"
24+
username: "admin"
25+
password: "{{ admin_password }}"
26+
27+
- name: Get all VMs
28+
azure.azcollection.azure_rm_virtualmachine_info:
29+
resource_group: "{{ az_resource_group }}"
30+
register: vm_info
31+
32+
- name: Filter cedge VMs
33+
ansible.builtin.set_fact:
34+
cedge_vms: "{{ vm_info.vms | selectattr('name', 'search', 'cedge') | list }}"
35+
36+
- name: Define deployment facts
37+
ansible.builtin.set_fact:
38+
deployment_facts:
39+
deployed_edge_instances: []
40+
41+
- name: Get params for cEdge
42+
ansible.builtin.include_tasks: az_cedge_ec2_instance.yml
43+
vars:
44+
hostname: "{{ item.name }}"
45+
public_ips: "{{ public_ip_info.publicipaddresses | selectattr('tags.Machine', 'equalto', item.name) | list }}"
46+
loop: "{{ cedge_vms }}"

0 commit comments

Comments
 (0)