diff --git a/.gitignore b/.gitignore index e2e936f..180c65e 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,4 @@ pip-selfcheck.json .retry group_vars/vmware *.ova +*.iso diff --git a/deploy-topo.yml b/deploy-topo.yml deleted file mode 100644 index 959ef82..0000000 --- a/deploy-topo.yml +++ /dev/null @@ -1,70 +0,0 @@ ---- -- hosts: localhost - name: Create per node data model - gather_facts: no - tags: [ model ] - roles: - - deploy-topo.yml - -## Second Play -- name: Generate Configuration for all routers - gather_facts: no -# connection: local - hosts: all - tags: [ template ] - tasks: - - include_vars: "./nodes.yml" -# - name: Gather facts (eos) -# eos_facts: -# when: -# - ansible_network_os == 'eos' -# - dryrun is not defined -# - name: Gather facts (junos) -# junos_facts: -# when: -# - ansible_network_os == 'junos' -# - dryrun is not defined - - name: create the directory for the configuration - file: path=core_config state=directory - run_once: true - - name: Generate Configuration - template: src={{ansible_network_os}}/core.j2 dest=core_config/{{inventory_hostname}}-config.txt - -## Third Play -# commit variable is used to control the play -# if commit=0 then we will not commit the changes we will only generate diff -# if commit=1 then we will commit the changes and generate diff -- name: push the configuration to the devices - gather_facts: no -# connection: local - hosts: all - tags: [ deploy ] - tasks: - - include_vars: "./nodes.yml" - - file: path=diff state=directory - run_once: true - - - name: Load config (junos) - junos_config: - src: core_config/{{inventory_hostname}}-config.txt - update: override - comment: Ansible config update - when: ansible_network_os == 'junos' - - - name: Load config (eos) - eos_config: - src: core_config/{{inventory_hostname}}-config.txt - when: ansible_network_os == 'eos' - -# - name: load the configuration to the devices -# napalm_install_config: -# hostname: "{{ ansible_host }}" -# username: "{{ ansible_user }}" -# dev_os: "{{ ansible_network_os }}" -# optional_args: -# key_file: "{{ ansible_ssh_private_key_file }}" -# config_file: core_config/{{inventory_hostname}}-config.txt -# commit_changes: "{{commit}}" -# replace_config: "{{replace_config|default('0')}}" -# diff_file: diff/{{inventory_hostname}}-diff.txt -# when: "inventory_hostname in nodes.keys()" diff --git a/dhcpd_config.yml b/dhcpd_config.yml new file mode 100644 index 0000000..9d52731 --- /dev/null +++ b/dhcpd_config.yml @@ -0,0 +1,46 @@ +--- +- name: generate dhcpd.hosts entries + hosts: srlab + gather_facts: no + vars_files: group_vars/vmware + tasks: + - name: gather facts + delegate_to: localhost + vmware_guest_facts: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" +# esxi_hostname: "{{ esxi_hostname }}" + validate_certs: False +# datastore: "host 2 - datastore 2" + datacenter: "NS Lab" +# cluster: "NS Lab" + name: "{{ inventory_hostname }}-vcp" + register: facts + - name: edit dhcpd.hosts + blockinfile: + path: /etc/dhcp/dhcpd.hosts + block: | + host {{ inventory_hostname }} { + hardware ethernet {{ facts.instance.hw_eth0.macaddress }}; + fixed-address {{ ansible_host }}; + option JUNOS.transfer-mode "http"; + option JUNOS.config-file-name "{{ inventory_hostname }}.conf"; + } + marker: "# {mark} ANSIBLE MANAGED BLOCK {{ inventory_hostname }}" + delegate_to: dhcpd + become: True + - name: restart dhcpd + systemd: + name: isc-dhcp-server + state: restarted + delegate_to: dhcpd + become: True + run_once: True + - name: deploy vmx configs + template: + src: templates/vmx_base.conf.j2 + dest: "/var/www/html/{{ inventory_hostname }}.conf" + mode: 0644 + delegate_to: dhcpd + become: True diff --git a/dhcpd_deploy_iso.yml b/dhcpd_deploy_iso.yml deleted file mode 100644 index ee392fa..0000000 --- a/dhcpd_deploy_iso.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Deploy an iso - hosts: localhost - tags: deploy_iso - gather_facts: no - vars_files: group_vars/vmware - tasks: - - name: Deploy the ubuntu iso - vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" - esxi_hostname: "{{ esxi_hostname }}" - validate_certs: False - name: "dhcpd" - datastore: datastore2 - folder: / - state: present - guest_id: ubuntu64Guest - cdrom: - type: iso - iso_path: "[datastore2] ISOs/ubuntu-18.04.1-live-server-amd64.iso" - disk: - - size_gb: 40 - type: thin - hardware: - memory_mb: 1024 - num_cpus: 2 - scsi: paravirtual - networks: - - name: NS-DEV-NAT - device_type: vmxnet3 diff --git a/dhcpd_server.yml b/dhcpd_server.yml index 0cad6c0..4e74d96 100644 --- a/dhcpd_server.yml +++ b/dhcpd_server.yml @@ -1,12 +1,32 @@ --- -# This playbook just apply debops.dhcpd Role to a target node. -- name: Infrastructure Services [DHCP server] +- name: Deploy Infrastructure Services [DHCP server] hosts: dhcpd become: True - - vars_files: - - vars-dhcpd.yml - - roles: - - role: debops.dhcpd - tags: dhcpd + tasks: + - name: Install ISC dhcpd + apt: + name: isc-dhcp-server + update_cache: yes + - name: copy dhcpd.conf + template: + src: templates/dhcpd.conf.j2 + dest: /etc/dhcp/dhcpd.conf + mode: 0644 + - name: create dhcpd.hosts + copy: + content: "" + dest: /etc/dhcp/dhcpd.hosts + force: no + mode: 0644 + - name: restart dhcpd + service: + name: isc-dhcp-server + state: restarted + - name: Install nginx + apt: + name: nginx + update_cache: yes + - name: start nginx + service: + name: nginx + state: started diff --git a/files/nodes.yml b/files/nodes.yml index 3f6d2ef..4423c0e 100644 --- a/files/nodes.yml +++ b/files/nodes.yml @@ -14,7 +14,7 @@ nodes: vlan: 0} ge-0/0/2.0: {cost: 1000, ip: 10.0.0.22, iso: true, mask: 31, mpls: true, remote: srlab-vmx3, vlan: 0} - mgmt: 10.39.0.57 + mgmt: 10.39.0.101 rid: 192.168.0.1 sid: 10 switches: [srlab-vmx1-0--srlab-vmx2-0, srlab-vmx1-1--srlab-vmx4-1, srlab-vmx1-2--srlab-vmx3-2] @@ -30,7 +30,7 @@ nodes: vlan: 0} ge-0/0/1.0: {cost: 1000, ip: 10.0.0.4, iso: true, mask: 31, mpls: true, remote: srlab-vmx5, vlan: 0} - mgmt: 10.39.0.58 + mgmt: 10.39.0.102 rid: 192.168.0.2 sid: 20 switches: [srlab-vmx1-0--srlab-vmx2-0, srlab-vmx2-1--srlab-vmx5-1] @@ -46,7 +46,7 @@ nodes: vlan: 0} ge-0/0/4.0: {cost: 1000, ip: 10.0.0.24, iso: true, mask: 31, mpls: true, remote: srlab-vmx6, vlan: 0} - mgmt: 10.39.0.59 + mgmt: 10.39.0.103 rid: 192.168.0.3 sid: 30 switches: [srlab-vmx1-2--srlab-vmx3-2, srlab-vmx3-4--srlab-vmx6-4] @@ -67,7 +67,7 @@ nodes: vlan: 0} ge-0/0/3.0: {cost: 1000, ip: 10.0.0.10, iso: true, mask: 31, mpls: true, remote: srlab-vmx6, vlan: 0} - mgmt: 10.39.0.60 + mgmt: 10.39.0.104 rid: 192.168.0.4 sid: 40 switches: [srlab-vmx4-0--srlab-vmx5-0, srlab-vmx1-1--srlab-vmx4-1, srlab-vmx4-2--srlab-vmx6-2, @@ -86,7 +86,7 @@ nodes: vlan: 0} ge-0/0/1.0: {cost: 1000, ip: 10.0.0.5, iso: true, mask: 31, mpls: true, remote: srlab-vmx2, vlan: 0} - mgmt: 10.39.0.55 + mgmt: 10.39.0.105 rid: 192.168.0.5 sid: 50 switches: [srlab-vmx4-0--srlab-vmx5-0, srlab-vmx2-1--srlab-vmx5-1, srlab-vmx5-2--srlab-vmx7-2, @@ -109,7 +109,7 @@ nodes: vlan: 0} ge-0/0/4.0: {cost: 1000, ip: 10.0.0.25, iso: true, mask: 31, mpls: true, remote: srlab-vmx3, vlan: 0} - mgmt: 10.39.0.56 + mgmt: 10.39.0.106 rid: 192.168.0.6 sid: 60 switches: [srlab-vmx6-0--srlab-vmx7-0, srlab-vmx6-1--srlab-vmx8-1, srlab-vmx4-2--srlab-vmx6-2, @@ -129,7 +129,7 @@ nodes: vlan: 0} ge-0/0/1.0: {cost: 1000, ip: 10.0.0.18, iso: true, mask: 31, mpls: true, remote: srlab-vmx9, vlan: 0} - mgmt: 10.39.0.57 + mgmt: 10.39.0.107 rid: 192.168.0.7 sid: 70 switches: [srlab-vmx6-0--srlab-vmx7-0, srlab-vmx7-1--srlab-vmx9-1, srlab-vmx5-2--srlab-vmx7-2, @@ -146,7 +146,7 @@ nodes: vlan: 0} ge-0/0/1.0: {cost: 1000, ip: 10.0.0.17, iso: true, mask: 31, mpls: true, remote: srlab-vmx6, vlan: 0} - mgmt: 10.39.0.58 + mgmt: 10.39.0.108 rid: 192.168.0.8 sid: 80 switches: [srlab-vmx8-0--srlab-vmx9-0, srlab-vmx6-1--srlab-vmx8-1] @@ -162,7 +162,7 @@ nodes: vlan: 0} ge-0/0/1.0: {cost: 1000, ip: 10.0.0.19, iso: true, mask: 31, mpls: true, remote: srlab-vmx7, vlan: 0} - mgmt: 10.39.0.59 + mgmt: 10.39.0.109 rid: 192.168.0.9 sid: 90 switches: [srlab-vmx8-0--srlab-vmx9-0, srlab-vmx7-1--srlab-vmx9-1] diff --git a/files/srlab-config/srlab-vmx1-config.txt b/files/srlab-config/srlab-vmx1-config.txt index d8ddc22..a0f7c36 100644 --- a/files/srlab-config/srlab-vmx1-config.txt +++ b/files/srlab-config/srlab-vmx1-config.txt @@ -77,7 +77,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.57/20; + address 10.39.0.101/20; } } } diff --git a/files/srlab-config/srlab-vmx2-config.txt b/files/srlab-config/srlab-vmx2-config.txt index a360ed6..272e10f 100644 --- a/files/srlab-config/srlab-vmx2-config.txt +++ b/files/srlab-config/srlab-vmx2-config.txt @@ -66,7 +66,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.58/20; + address 10.39.0.102/20; } } } diff --git a/files/srlab-config/srlab-vmx3-config.txt b/files/srlab-config/srlab-vmx3-config.txt index 5da309b..625ba83 100644 --- a/files/srlab-config/srlab-vmx3-config.txt +++ b/files/srlab-config/srlab-vmx3-config.txt @@ -66,7 +66,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.59/20; + address 10.39.0.103/20; } } } diff --git a/files/srlab-config/srlab-vmx4-config.txt b/files/srlab-config/srlab-vmx4-config.txt index 9f808ce..449b341 100644 --- a/files/srlab-config/srlab-vmx4-config.txt +++ b/files/srlab-config/srlab-vmx4-config.txt @@ -88,7 +88,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.60/20; + address 10.39.0.104/20; } } } diff --git a/files/srlab-config/srlab-vmx5-config.txt b/files/srlab-config/srlab-vmx5-config.txt index e64603d..8e8f500 100644 --- a/files/srlab-config/srlab-vmx5-config.txt +++ b/files/srlab-config/srlab-vmx5-config.txt @@ -96,7 +96,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.55/20; + address 10.39.0.105/20; } } } diff --git a/files/srlab-config/srlab-vmx6-config.txt b/files/srlab-config/srlab-vmx6-config.txt index b3d2fed..a9310cb 100644 --- a/files/srlab-config/srlab-vmx6-config.txt +++ b/files/srlab-config/srlab-vmx6-config.txt @@ -99,7 +99,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.56/20; + address 10.39.0.106/20; } } } diff --git a/files/srlab-config/srlab-vmx7-config.txt b/files/srlab-config/srlab-vmx7-config.txt index d221854..4c5985b 100644 --- a/files/srlab-config/srlab-vmx7-config.txt +++ b/files/srlab-config/srlab-vmx7-config.txt @@ -96,7 +96,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.57/20; + address 10.39.0.107/20; } } } diff --git a/files/srlab-config/srlab-vmx8-config.txt b/files/srlab-config/srlab-vmx8-config.txt index ba19ccf..71579f9 100644 --- a/files/srlab-config/srlab-vmx8-config.txt +++ b/files/srlab-config/srlab-vmx8-config.txt @@ -66,7 +66,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.58/20; + address 10.39.0.108/20; } } } diff --git a/files/srlab-config/srlab-vmx9-config.txt b/files/srlab-config/srlab-vmx9-config.txt index ff60865..c8d1763 100644 --- a/files/srlab-config/srlab-vmx9-config.txt +++ b/files/srlab-config/srlab-vmx9-config.txt @@ -66,7 +66,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.59/20; + address 10.39.0.109/20; } } } diff --git a/files/srlab-tasks/srlab-vmx1_task.yml b/files/srlab-tasks/srlab-vmx1_task.yml index 5e64c86..8f16197 100644 --- a/files/srlab-tasks/srlab-vmx1_task.yml +++ b/files/srlab-tasks/srlab-vmx1_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx1-vfpc" diff --git a/files/srlab-tasks/srlab-vmx2_task.yml b/files/srlab-tasks/srlab-vmx2_task.yml index 38f71c2..e63b671 100644 --- a/files/srlab-tasks/srlab-vmx2_task.yml +++ b/files/srlab-tasks/srlab-vmx2_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx2-vfpc" diff --git a/files/srlab-tasks/srlab-vmx3_task.yml b/files/srlab-tasks/srlab-vmx3_task.yml index 242558d..24252f3 100644 --- a/files/srlab-tasks/srlab-vmx3_task.yml +++ b/files/srlab-tasks/srlab-vmx3_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx3-vfpc" diff --git a/files/srlab-tasks/srlab-vmx4_task.yml b/files/srlab-tasks/srlab-vmx4_task.yml index 5ea5eb1..a5ca4cf 100644 --- a/files/srlab-tasks/srlab-vmx4_task.yml +++ b/files/srlab-tasks/srlab-vmx4_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx4-vfpc" diff --git a/files/srlab-tasks/srlab-vmx5_task.yml b/files/srlab-tasks/srlab-vmx5_task.yml index 14adc4a..26d73f4 100644 --- a/files/srlab-tasks/srlab-vmx5_task.yml +++ b/files/srlab-tasks/srlab-vmx5_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx5-vfpc" diff --git a/files/srlab-tasks/srlab-vmx6_task.yml b/files/srlab-tasks/srlab-vmx6_task.yml index 52e05df..c9ba08b 100644 --- a/files/srlab-tasks/srlab-vmx6_task.yml +++ b/files/srlab-tasks/srlab-vmx6_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx6-vfpc" diff --git a/files/srlab-tasks/srlab-vmx7_task.yml b/files/srlab-tasks/srlab-vmx7_task.yml index 567b415..132d92a 100644 --- a/files/srlab-tasks/srlab-vmx7_task.yml +++ b/files/srlab-tasks/srlab-vmx7_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx7-vfpc" diff --git a/files/srlab-tasks/srlab-vmx8_task.yml b/files/srlab-tasks/srlab-vmx8_task.yml index b878ddf..7d4640b 100644 --- a/files/srlab-tasks/srlab-vmx8_task.yml +++ b/files/srlab-tasks/srlab-vmx8_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx8-vfpc" diff --git a/files/srlab-tasks/srlab-vmx9_task.yml b/files/srlab-tasks/srlab-vmx9_task.yml index 87861ca..76663fb 100644 --- a/files/srlab-tasks/srlab-vmx9_task.yml +++ b/files/srlab-tasks/srlab-vmx9_task.yml @@ -1,8 +1,8 @@ - name: Update vmx networking vmware_guest: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False name: "srlab-vmx9-vfpc" diff --git a/hosts.ini b/hosts.ini index 9d9b93e..43ba81d 100644 --- a/hosts.ini +++ b/hosts.ini @@ -1,13 +1,13 @@ [srlab] -srlab-vmx1 ansible_host=10.0.0.1 -srlab-vmx2 ansible_host=10.0.0.2 -srlab-vmx3 ansible_host=10.0.0.3 -srlab-vmx4 ansible_host=10.0.0.4 -srlab-vmx5 ansible_host=10.0.0.5 -srlab-vmx6 ansible_host=10.0.0.6 -srlab-vmx7 ansible_host=10.0.0.7 -srlab-vmx8 ansible_host=10.0.0.8 -srlab-vmx9 ansible_host=10.0.0.9 +srlab-vmx1 ansible_host=10.39.0.101 +srlab-vmx2 ansible_host=10.39.0.102 +srlab-vmx3 ansible_host=10.39.0.103 +srlab-vmx4 ansible_host=10.39.0.104 +srlab-vmx5 ansible_host=10.39.0.105 +srlab-vmx6 ansible_host=10.39.0.106 +srlab-vmx7 ansible_host=10.39.0.107 +srlab-vmx8 ansible_host=10.39.0.108 +srlab-vmx9 ansible_host=10.39.0.109 [vmxlab] vmx1 ansible_host=10.39.8.10 diff --git a/site.yml b/site.yml deleted file mode 100644 index e69de29..0000000 diff --git a/srlab-deploy.yml b/srlab-deploy.yml index f6a364d..ea5bf27 100644 --- a/srlab-deploy.yml +++ b/srlab-deploy.yml @@ -7,9 +7,9 @@ tasks: - name: Create the vswitch vmware_vswitch: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False switch_name: "{{ inventory_hostname }}-br-int" @@ -17,9 +17,9 @@ delegate_to: localhost - name: Create the portgroup vmware_portgroup: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False switch_name: "{{ inventory_hostname }}-br-int" @@ -40,9 +40,9 @@ - include_vars: "files/nodes.yml" - name: Create the vswitch vmware_vswitch: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False switch_name: "{{ item }}" @@ -51,9 +51,9 @@ delegate_to: localhost - name: Create the portgroup vmware_portgroup: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" validate_certs: False switch_name: "{{ item }}" @@ -74,13 +74,13 @@ tasks: - name: Deploy the vcp ova vmware_deploy_ovf: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" validate_certs: False allow_duplicates: no name: "{{ inventory_hostname }}-vcp" - datastore: datastore2 + datastore: "host 2 - datastore 2" ova: files/ova/vcp_17.3R3.10.ova disk_provisioning: thin power_on: no @@ -90,13 +90,13 @@ delegate_to: localhost - name: Deploy the vfpc ova vmware_deploy_ovf: - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" validate_certs: False allow_duplicates: no name: "{{ inventory_hostname }}-vfpc" - datastore: datastore2 + datastore: "host 2 - datastore 2" ova: files/ova/vfpc_17.3R3.10.ova disk_provisioning: thin power_on: no diff --git a/srlab-poweron.yml b/srlab-poweron.yml new file mode 100644 index 0000000..005bae6 --- /dev/null +++ b/srlab-poweron.yml @@ -0,0 +1,31 @@ +--- +- name: Power on srlab + hosts: srlab + tags: poweron + gather_facts: no + vars_files: group_vars/vmware + tasks: + - name: power on vfpc + vmware_guest: + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" + esxi_hostname: "{{ esxi_hostname }}" + validate_certs: False + name: "{{ inventory_hostname }}-vfpc" + folder: / + datastore: "host 2 - datastore 2" + state: poweredon + delegate_to: localhost + - name: power on vcp + vmware_guest: + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" + esxi_hostname: "{{ esxi_hostname }}" + validate_certs: False + name: "{{ inventory_hostname }}-vcp" + folder: / + datastore: "host 2 - datastore 2" + state: poweredon + delegate_to: localhost diff --git a/templates/dhcpd.conf.j2 b/templates/dhcpd.conf.j2 new file mode 100644 index 0000000..85f8a88 --- /dev/null +++ b/templates/dhcpd.conf.j2 @@ -0,0 +1,25 @@ +# option definitions common to all supported networks... +option domain-name "internet2.edu"; +option domain-name-servers 207.75.164.59, 192.52.179.250; + +default-lease-time 600; +max-lease-time 7200; + +subnet 10.39.0.0 netmask 255.255.248.0 { + option routers 10.39.0.1; + option broadcast-address 10.39.7.255; +} + +option space JUNOS; +option JUNOS.config-file-name code 1 = text; +option JUNOS.image-file-name code 0 = text; +option JUNOS.image-file-type code 2 = text; +option JUNOS.transfer-mode code 3 = text; +option JUNOS.alt-image-file-name code 4= text; +option JUNOS.http-port code 5= text; +option JUNOS-encapsulation code 43 = encapsulate JUNOS; + +option option-150 code 150={ip-address}; +option option-150 {{ ansible_host }}; + +include "/etc/dhcp/dhcpd.hosts"; diff --git a/templates/dhcpd.hosts b/templates/dhcpd.hosts new file mode 100644 index 0000000..6d8a484 --- /dev/null +++ b/templates/dhcpd.hosts @@ -0,0 +1,55 @@ + +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx2 +host srlab-vmx2 { + hardware ethernet 00:0c:29:7d:da:4b + fixed-address 10.0.0.2 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx2 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx5 +host srlab-vmx5 { + hardware ethernet 00:0c:29:ff:5b:ba + fixed-address 10.0.0.5 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx5 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx3 +host srlab-vmx3 { + hardware ethernet 00:0c:29:95:ef:a5 + fixed-address 10.0.0.3 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx3 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx4 +host srlab-vmx4 { + hardware ethernet 00:0c:29:9f:ff:23 + fixed-address 10.0.0.4 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx4 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx1 +host srlab-vmx1 { + hardware ethernet 00:0c:29:49:66:d0 + fixed-address 10.0.0.1 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx1 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx6 +host srlab-vmx6 { + hardware ethernet 00:0c:29:08:e9:4c + fixed-address 10.0.0.6 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx6 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx7 +host srlab-vmx7 { + hardware ethernet 00:0c:29:f3:da:36 + fixed-address 10.0.0.7 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx7 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx8 +host srlab-vmx8 { + hardware ethernet 00:0c:29:53:ee:9a + fixed-address 10.0.0.8 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx8 +# BEGIN ANSIBLE MANAGED BLOCK srlab-vmx9 +host srlab-vmx9 { + hardware ethernet 00:0c:29:fe:b1:11 + fixed-address 10.0.0.9 +} +# END ANSIBLE MANAGED BLOCK srlab-vmx9 diff --git a/templates/task_update_network.j2 b/templates/task_update_network.j2 index 45d99c6..bf11b75 100644 --- a/templates/task_update_network.j2 +++ b/templates/task_update_network.j2 @@ -1,9 +1,9 @@ - name: Update vmx networking vmware_guest: {%- raw %} - hostname: "{{ vcenter_hostname }}" - username: "{{ vcenter_username }}" - password: "{{ vcenter_password }}" + hostname: "{{ esxi_hostname }}" + username: "{{ esxi_username }}" + password: "{{ esxi_password }}" esxi_hostname: "{{ esxi_hostname }}" {% endraw %} validate_certs: False diff --git a/templates/vmx_base.conf.j2 b/templates/vmx_base.conf.j2 new file mode 100644 index 0000000..39682a0 --- /dev/null +++ b/templates/vmx_base.conf.j2 @@ -0,0 +1,39 @@ +system { + host-name {{ inventory_hostname }}; + root-authentication { + encrypted-password "$5$dtzjbbOB$kRjqCbWTMGPGR182yFSH/yD1dUEt7uKn1DHEaQUWgt6"; ## SECRET-DATA + } + login { + user salt { + uid 2001; + class super-user; + authentication { + ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjxY2hLZ+ju5wdK4GYNhKGgnS8EWLBoEVpo+xQkhDzkTiBx3HGAnmARcVV0B9MqrHZl1omdnirJeygWzVbVY4yPUqGgEcUsTTq9fvK4AjTwtaoB5txAosaOnZq0zewmuZ6EMi6E3RND6A3FGXkf1Il2jg3I8k/dGqdyFI80B7sWy90fk+EqsGMPxVc+l5vAtY2jm84ellxxzBsulxfCSKPH86hZ1GqZ8A1ZBWITu15NjQw0aGssSYGMMTa1T8eFyY4hHWqqdwgOlODg9mZwwP1JdJH79SRoTOjqGGixuAFDGAgH3fNX6u8wTmYya/z7WXH6B2XwiiaZYdcyEbMLPZt"; ## SECRET-DATA + } + } + } + services { + ssh { + protocol-version v2; + } + netconf { + ssh; + } + } +} +interfaces { + fxp0 { + unit 0 { + family inet { + address {{ ansible_host }}/21; + } + } + } +} +routing-options { + static { + route 0.0.0.0/0 { + next-hop 10.39.0.1; + } + } +} diff --git a/vars_files/core-model-sr.yml b/vars_files/core-model-sr.yml index b56d885..38206db 100644 --- a/vars_files/core-model-sr.yml +++ b/vars_files/core-model-sr.yml @@ -5,55 +5,55 @@ common: nodes: - name: srlab-vmx1 - mgmt: 10.39.0.57 + mgmt: 10.39.0.101 rid: 192.168.0.1 sid: 10 iso: 49.0001.0010.0100.1001.00 - name: srlab-vmx2 - mgmt: 10.39.0.58 + mgmt: 10.39.0.102 rid: 192.168.0.2 sid: 20 iso: 49.0001.0010.0100.1002.00 - name: srlab-vmx3 - mgmt: 10.39.0.59 + mgmt: 10.39.0.103 rid: 192.168.0.3 sid: 30 iso: 49.0001.0010.0100.1003.00 - name: srlab-vmx4 - mgmt: 10.39.0.60 + mgmt: 10.39.0.104 rid: 192.168.0.4 sid: 40 iso: 49.0001.0010.0100.1004.00 - name: srlab-vmx5 - mgmt: 10.39.0.55 + mgmt: 10.39.0.105 rid: 192.168.0.5 sid: 50 iso: 49.0001.0010.0100.1005.00 - name: srlab-vmx6 - mgmt: 10.39.0.56 + mgmt: 10.39.0.106 rid: 192.168.0.6 sid: 60 iso: 49.0001.0010.0100.1006.00 - name: srlab-vmx7 - mgmt: 10.39.0.57 + mgmt: 10.39.0.107 rid: 192.168.0.7 sid: 70 iso: 49.0001.0010.0100.1007.00 - name: srlab-vmx8 - mgmt: 10.39.0.58 + mgmt: 10.39.0.108 rid: 192.168.0.8 sid: 80 iso: 49.0001.0010.0100.1008.00 - name: srlab-vmx9 - mgmt: 10.39.0.59 + mgmt: 10.39.0.109 rid: 192.168.0.9 sid: 90 iso: 49.0001.0010.0100.1009.00 diff --git a/vmware_clone_template.yml b/vmware_clone_template.yml new file mode 100644 index 0000000..e3a4ccd --- /dev/null +++ b/vmware_clone_template.yml @@ -0,0 +1,48 @@ +--- +- name: Clone a template + hosts: all + tags: deploy_iso + gather_facts: no + vars_files: group_vars/vmware + tasks: + - name: Clone the template + delegate_to: localhost + vmware_guest: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" +# esxi_hostname: "{{ esxi_hostname }}" + validate_certs: False + name: "{{ inventory_hostname }}" + datastore: "host 2 - datastore 2" + datacenter: "NS Lab" +# cluster: "NS Lab" + folder: "/" + state: poweredon + guest_id: ubuntu64Guest + template: ubuntu-template + disk: + - size_gb: 40 + type: thin + hardware: + memory_mb: 1024 + num_cpus: 2 + scsi: paravirtual + networks: + - name: NS-DEV-NAT + device_type: vmxnet3 + start_connected: True + allow_guest_control: True + ip: "{{ ansible_host }}" + netmask: 255.255.248.0 + gateway: 10.39.0.1 + dns_servers: + - 207.75.164.59 + - 192.52.179.250 + customization: + dns_servers: + - 207.75.164.59 + - 192.52.179.250 + domain: internet2.edu + hostname: "{{ inventory_hostname }}" +