diff options
author | Peter Mikus <pmikus@cisco.com> | 2018-05-19 15:15:29 +0200 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2018-05-30 09:49:59 +0000 |
commit | 3a14297dca576dd7e2c9f09d84bf0f5cf58c1938 (patch) | |
tree | 56de2207a8260d2204f6ce3bc7dbadcfb6e96417 /resources/tools/testbed-setup/ansible/roles/virl/tasks | |
parent | 8bb12f5b902cf42c623172c562b4f2752489bc13 (diff) |
CSIT-1070 Update Ansible structure
Change-Id: I9adab174f0c15f4c05a93f61b17714fa6542ea5d
Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/tools/testbed-setup/ansible/roles/virl/tasks')
4 files changed, 408 insertions, 0 deletions
diff --git a/resources/tools/testbed-setup/ansible/roles/virl/tasks/02-virl-bootstrap.yaml b/resources/tools/testbed-setup/ansible/roles/virl/tasks/02-virl-bootstrap.yaml new file mode 100644 index 0000000000..9ffb40caaf --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/virl/tasks/02-virl-bootstrap.yaml @@ -0,0 +1,216 @@ +--- + - name: install virl-bootstrap + git: + repo: 'https://github.com/VIRL-Open/virl-bootstrap.git' + dest: /home/virl/virl-bootstrap + version: xenial + become_user: virl + - name: copy vsetting file to /etc + shell: /usr/bin/install -m 666 /home/virl/virl-bootstrap/vsettings.ini /etc/virl.ini + become: yes + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT hostname {{ hostname }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT domain_name linuxfoundation.org + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT using_dhcp_on_the_public_port False + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT public_port dummy3 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT Static_IP 10.30.49.28 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT public_network 10.30.49.0 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT public_netmask {{ ansible_default_ipv4["netmask"] }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT public_gateway 10.30.49.1 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT proxy False + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT ntp_server pool.ntp.org + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT first_nameserver 199.204.44.24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT second_nameserver 199.204.47.54 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT salt_master vsm-md.virl.info + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT salt_id {{ hostname }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT salt_domain linuxfoundation.org + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT salt_masterless false + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_port {{ virl_public_port }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_network {{ virl_l2_network }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_mask 255.255.255.0 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_network_gateway {{ virl_l2_gateway }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_start_address {{ virl_l2_start }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_end_address {{ virl_l2_end }} + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_address {{ ansible_default_ipv4["address"] }}/24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT first_flat_nameserver 199.204.44.24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT second_flat_nameserver 199.204.47.54 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_port2_enabled True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_port2 dummy0 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_network2 172.16.2.0/24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_mask2 255.255.255.0 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_network_gateway2 172.16.2.1 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_start_address2 172.16.2.50 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_end_address2 172.16.2.253 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l2_address2 172.16.2.254/24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT first_flat2_nameserver 199.204.44.24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT second_flat2_nameserver 199.204.47.54 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l3_port dummy1 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l3_network 172.16.3.0/24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l3_mask 255.255.255.0 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l3_network_gateway 172.16.3.1 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l3_floating_start_address 172.16.3.50 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l3_floating_end_address 172.16.3.253 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT l3_address 172.16.3.254/24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT first_snat_nameserver 199.204.44.24 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT second_snat_nameserver 199.204.47.54 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT ramdisk True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT ank 19401 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT ank_live 19402 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT virl_webservices 19399 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT virl_user_management 19400 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT virl_apache_port 80 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT virl_webmux 19403 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT Start_of_serial_port_range 17000 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT End_of_serial_port_range 18000 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT serial_port 19406 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT vnc_port 19407 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT location_region US + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT vnc False + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT guest_account True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT user_list tb4-virl:Cisco1234 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT uwmadmin_password Cisco1234 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT password password + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT mysql_password password + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT keystone_service_token fkgjhsdflkjh + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT enable_cinder True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT cinder_file True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT cinder_size 20000 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT cinder_location /var/lib/cinder/cinder-volumes.lvm + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT dummy_int True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT this_node_is_the_controller True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT internalnet_controller_hostname controller + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT internalnet_controller_IP 172.16.10.250 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT internalnet_port dummy2 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT internalnet_IP 172.16.10.250 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT internalnet_network 172.16.10.0 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT internalnet_netmask 255.255.255.0 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT internalnet_gateway 172.16.10.1 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT iosv True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT csr1000v True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT iosxrv432 False + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT iosxrv52 False + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT iosxrv True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT nxosv True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT vpagent True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT iosvl2 True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT asav True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT lxc_server True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT lxc_iperf True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT lxc_routem True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT lxc_ostinato True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT server True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT vmm_mac True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT vmm_win32 True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT vmm_win64 True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT vmm_linux True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT virl_clients True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT ram_overcommit 2 + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT web_editor True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT mitaka True + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT kilo False + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT libvirt_cpu_mode host-passthrough + become_user: virl + - command: crudini --inplace --set /etc/virl.ini DEFAULT neutron_bridge_flooding True + become_user: virl + - name: copy vinstall bootstrap wrapper script + template: src=files/virl/virl-bootstrap-wrapper dest=/home/virl/virl-bootstrap/virl-bootstrap-wrapper owner=virl group=virl mode=775 + become_user: virl diff --git a/resources/tools/testbed-setup/ansible/roles/virl/tasks/03-virl-post-install.yaml b/resources/tools/testbed-setup/ansible/roles/virl/tasks/03-virl-post-install.yaml new file mode 100644 index 0000000000..44b9df2098 --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/virl/tasks/03-virl-post-install.yaml @@ -0,0 +1,87 @@ +--- + - name: Add jenkins-in user + user: name=jenkins-in shell=/bin/bash comment="Jenkins user" + - name: Add jenkins-in user to sudoers + copy: src=files/sudoers_jenkins-in dest=/etc/sudoers.d/jenkins-in owner=root group=root mode=660 + - name: Set Jenkins user authorized key + authorized_key: user=jenkins-in key="{{ lookup('file', '/home/testuser/.ssh/id_rsa.pub') }}" + - name: copy salt states for dnsmasq and nfs + synchronize: src=files/salt/ dest=/ + - name: install NFS salt + shell: salt-call --local state.sls ckoester.nfs-server + - name: NFS symlink + shell: ln -s /nfs/scratch /scratch + args: + creates: /scratch + - name: Upate Nova CPU mode + ini_file: dest=/etc/nova/nova.conf section=libvirt option=cpu_mode value=host-passthrough + - name: Restart nova-compute service + service: name=nova-compute state=restarted + - name: Change listen interface in NTP settings + lineinfile: dest=/etc/ntp.conf state=present regexp='^interface listen 172.16.*' line='interface listen {{ ansible_default_ipv4["address"] }}' + - name: Restart NTP service + service: name=ntp state=restarted + - name: Permit SSH user environment + lineinfile: dest=/etc/ssh/sshd_config state=present regexp='PermitUserEnvironment.*' line='PermitUserEnvironment yes' + - name: Restart SSH daemon + service: name=ssh state=restarted + - name: clone csit git repository + git: repo=https://gerrit.fd.io/r/csit + dest=/home/jenkins-in/git/csit + become: jenkins-in + - name: Link testcase-infra directory + command: ln -sf /home/jenkins-in/git/csit/resources/tools/virl /home/jenkins-in/testcase-infra + args: + creates: /home/jenkins-in/testcase-infra + become: jenkins-in + - name: Create bin directory + file: path=/home/jenkins-in/bin state=directory mode=0755 + become: jenkins-in + - name: Link start-testcase executable + command: ln -sf /home/jenkins-in/testcase-infra/bin/start-testcase /home/jenkins-in/bin/start-testcase + args: + creates: /home/jenkins-in/bin/start-testcase + become: jenkins-in + - name: Link stop-testcase executable + command: ln -sf /home/jenkins-in/testcase-infra/bin/stop-testcase /home/jenkins-in/bin/stop-testcase + args: + creates: /home/jenkins-in/bin/stop-testcase + become: jenkins-in + - name: Link kill-idle-testcases executable + command: ln -sf /home/jenkins-in/testcase-infra/bin/kill-idle-testcases /home/jenkins-in/bin/kill-idle-testcases + args: + creates: /home/jenkins-in/bin/kill-idle-testcases + become: jenkins-in + - name: Copy SSH private key + copy: src=files/virl/id_rsa_virl dest=/home/jenkins-in/.ssh/id_rsa_virl mode=600 + become: jenkins-in + - name: Copy SSH public key + copy: src=files/virl/id_rsa_virl.pub dest=/home/jenkins-in/.ssh/id_rsa_virl.pub mode=644 + become: jenkins-in + - name: Copy SSH environment + copy: src=files/virl/ssh_environment dest=/home/jenkins-in/.ssh/environment mode=644 + become: jenkins-in + - name: Add ~/bin to path + lineinfile: dest=/home/jenkins-in/.bashrc state=present line='PATH=${HOME}/bin:$PATH' + become: jenkins-in + - name: Update own IP address in start script + shell: sed -i /home/jenkins-in/testcase-infra/bin/start-testcase -e 's/10.30.51.28/{{ ansible_default_ipv4["address"] }}/' + become: jenkins-in + - name: Add authorized key + lineinfile: dest=/home/jenkins-in/.ssh/authorized_keys line='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD4gderzsZyoxHULjuvPHoJuKnkaGrykqtuoqs/k1/jUdxitPoY5eX2cVYqww7MiUif7zLsiXbt5mHtyxAYCluDxAuIcy1xgSZY3MpmmSqDie4A/FdVfCUqCcpf3TZKsRP0an1MNrKIe0JFZV+uU889IDRQRdboGMs3+4cn5b9fOutpv71qwFVrTm9PZbqfQonrrN8Jp4Mz3XaZDpK22xwDAWhYOZ0eV6CJWquUgbYAHE6/HHMvd0zeJKaWZCXO/1tOGOj6cjgoViHqbnCtmYCjmv/ir0IglzbUdWdOqQY5YkhnPonveV48lVKrmBipqgbDezAUQD8wOQ7HttpYpKgt jenkins-in@tb4-virl' + become: jenkins-in +# All of the below will fail if VIRL user/project already exist + - name: Create VIRL project + shell: virl_uwm_client project-edit --name tb4-virl --enabled True -i 400 -r 1024000 -c 500 + ignore_errors: true + become: virl +# - name: Delete VIRL project user +# shell: virl_uwm_client user-delete --name tb4-virl +# ignore_errors: true +# - name: Recreate VIRL project user +# shell: virl_uwm_client user-create --name tb4-virl --role admin --project tb4-virl --set-password Cisco1234 +# ignore_errors: true + - name: Create VPP flavor + shell: virl_uwm_client flavor-create --name vPP --ram 4096 --vcpus 2 --disk 0 + ignore_errors: true + become: virl diff --git a/resources/tools/testbed-setup/ansible/roles/virl/tasks/04-disk-image.yaml b/resources/tools/testbed-setup/ansible/roles/virl/tasks/04-disk-image.yaml new file mode 100644 index 0000000000..254c05e709 --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/virl/tasks/04-disk-image.yaml @@ -0,0 +1,27 @@ +--- + - name: Create server image directory + file: path=/home/virl/virl-server-image state=directory mode=0755 + become: virl + - name: Copy UBUNTU server image + copy: src=/home/virl/virl-server-image/packer-csit-ubuntu-16.04.1_2017-10-21_2.0-qemu dest=/home/virl/virl-server-image/packer-csit-ubuntu-16.04.1_2017-10-21_2.0-qemu owner=virl group=virl mode=644 + become: virl + - name: Copy CENTOS server image + copy: src=/home/virl/virl-server-image/packer-csit-centos-7.3-1611_2017-02-23_1.4-qemu dest=/home/virl/virl-server-image/packer-csit-centos-7.3-1611_2017-02-23_1.4-qemu owner=virl group=virl mode=644 + become: virl + - name: Import UBUNTU server image into glance + shell: virl_uwm_client image-create --subtype server --version csit-ubuntu-16.04.1_2017-10-21_2.0 --image-on-server /home/virl/virl-server-image/packer-csit-ubuntu-16.04.1_2017-10-21_2.0-qemu + become: virl + - name: Import CENTOS server image into glance + shell: virl_uwm_client image-create --subtype server --version csit-centos-7.3-1611_2017-02-23_1.4 --image-on-server /home/virl/virl-server-image/packer-csit-centos-7.3-1611_2017-02-23_1.4-qemu + become: virl + - name: Create common directory + file: path=/nfs/common state=directory mode=0755 + - name: Create Nested VM directory + file: path=/nfs/common/nested-vm state=directory mode=0755 + - name: Copy Nested VM image + copy: src=/home/virl/virl-server-image/csit-nested-1.6.img dest=/nfs/common/nested-vm/csit-nested-1.6.img owner=virl group=virl mode=644 + - name: NFS symlink + file: + src: /nfs/common/nested-vm-current.img.disabled + dest: /nfs/common/nested-vm/csit-nested-1.6.img + state: link diff --git a/resources/tools/testbed-setup/ansible/roles/virl/tasks/main.yaml b/resources/tools/testbed-setup/ansible/roles/virl/tasks/main.yaml new file mode 100644 index 0000000000..8bca04e163 --- /dev/null +++ b/resources/tools/testbed-setup/ansible/roles/virl/tasks/main.yaml @@ -0,0 +1,78 @@ +--- +- name: Interfaces file + template: + src: "files/interfaces_virl" + dest: "/etc/network/interfaces owner=root group=root mode=644" + tags: interfaces + +- name: Add VIRL user + user: + name: virl + shell: "/bin/bash" + comment: "VIRL user" + password: "$6$mJPlK5FKLar6$xxXPP0LRhC7T1yhHtym18Z3nKZweTtfTxzi1WpvVHJ0U/Em1UWcHqfMhRApFp0rsY9jHRuL6FfeFbKPN..uDK." + tags: users + +- name: Add VIRL user to sudoers + copy: + src: "files/sudoers_virl" + dest: "/etc/sudoers.d/virl owner=root group=root mode=660" + tags: sudoers + +- name: Add post up for additional address + copy: + src: "files/ifup" + dest: "/etc/network/if-up.d/virl owner=root group=root mode=755" + tags: interfaces + +- name: Set VIRL user authorized key + authorized_key: + user: virl + key: "{{ lookup('file', '/home/testuser/.ssh/id_rsa.pub') }}" + tags: users + +- name: Install bridge-utils + apt: + name: "bridge-utils" + state: "present" + tags: apt-install-bridge-utils + +- name: Old interface naming + command: "ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules" + tags: interfaces + +- name: Update init for old interface naming + command: "update-initramfs -u" + tags: interfaces + +- name: QEMU log garbage collector + cron: + minute: "0" + hour: "0" + name: "QEMU log garbage collector" + job: "find /var/log/libvirt/qemu -type f -mtime +14 -name 'instance*.log' -delete" + tags: cron + +- name: VPP deb package garbage collector + cron: + minute: "0" + hour: "0" + name: "VPP deb package garbage collector" + job: "find /tmp -type f -atime +14 -name '*.deb' -delete" + tags: cron + +- name: VPP rpm package garbage collector + cron: + minute: "0" + hour: "0" + name: "VPP rpm package garbage collector" + job: "find /tmp -type f -atime +14 -name '*.rpm' -delete" + tags: cron + +- name: NFS scratch dir garbage collector + cron: + minute: "0" + hour: "0" + name: "NFS scratch dir garbage collector" + job: "find /nfs/scratch/ -type d -mtime +1 -name 'session-*' -exec rm -r '{}' \\;" + tags: cron |