CSIT-770 Installation of prerequisites on physical hosts
[csit.git] / resources / tools / testbed-setup / README.md
1 # Testbed Setup
2
3 ## Introduction
4
5 This directoctory contains the *high-level* process to set up a hardware
6 machine as a CSIT testbed, either for use as a physical testbed host or
7 as a VIRL server.
8
9 Code in this directory is NOT executed as part of a regular CSIT test case
10 but is stored here merely for archiving and documentation purposes.
11
12
13 ## Setting up a hardware host
14
15 Documentation below is just bullet points and assumes and understanding
16 of PXE boot and ansible.
17
18 This process is specific for LF lab, and both examples given here as
19 well as associated code, are based on the assumption that they are run
20 in LF environment. If run elsewhere, changes will be required to IP addresses
21 and other parameters.
22
23 The process below assumes that there is a host used for boostrapping (referred
24 to as "PXE boostrap server" below), and that the directory containig this README
25 is available on the PXE bootstrap server in ~testuser/host-setup.
26
27 ### Prepare the PXE bootstrap server (one-time)
28
29   - `sudo apt-get install isc-dhcp-server tftpd-hpa nginx-light ansible`
30   - edit dhcpd.conf and place it to /etc/dhcp/
31   - `sudo cp dhcpd.cfg /etc/dhcp/`
32   - `sudo service isc-dhcp-server restart`
33   - `cd ~testuser/host-setup`
34   - `wget 'http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-server-amd64.iso'`
35   - `sudo mkdir /mnt/cdrom`
36   - `sudo mount -o loop ubuntu-16.04.2-server-amd64.iso /mnt/cdrom/`
37   - `sudo cp -r /mnt/cdrom/install/netboot/* /var/lib/tftpboot/`
38   - `sudo mkdir /usr/share/nginx/html/ubuntu`
39   - `sudo cp -r /mnt/cdrom/* /usr/share/nginx/html/ubuntu/`
40   - `sudo cp /mnt/cdrom/ubuntu/isolinux/ldlinux.c32 /var/lib/tftpboot`
41   - `sudo cp /mnt/cdrom/ubuntu/isolinux/libcom32.c32 /var/lib/tftpboot`
42   - `sudo cp /mnt/cdrom/ubuntu/isolinux/libutil.c32 /var/lib/tftpboot`
43   - `sudo cp /mnt/cdrom/ubuntu/isolinux/chain.c32 /var/lib/tftpboot`
44   - `sudo umount /mnt/cdrom`
45   - edit ks.cfg and replace IP address with that of your PXE bootstrap server
46   - `sudo cp ks.cfg /usr/share/nginx/html/ks.cfg`
47   - edit boot-screens_txt.cfg and replace IP address with that of your PXE bootstrap server
48   - `sudo cp boot-screens_txt.cfg /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg`
49   - `sudo cp syslinux.cfg /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/syslinux.cfg`
50
51 ### PREFERED: Prepare the PXE bootstrap server (alternative way without NGINX)
52
53   - `sudo apt-get install isc-dhcp-server tftpd-hpa ansible`
54   - edit dhcpd.conf and place it to /etc/dhcp/
55   - `sudo cp dhcpd.cfg /etc/dhcp/`
56   - `sudo service isc-dhcp-server restart`
57   - `cd ~testuser/host-setup`
58   - `wget 'http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-server-amd64.iso'`
59   - `sudo mkdir /mnt/cdrom`
60   - `sudo mount -o loop ubuntu-16.04.1-server-amd64.iso /mnt/cdrom/`
61   - `sudo cp -r /mnt/cdrom/install/netboot/* /var/lib/tftpboot/`
62   - `sudo mkdir /var/www/download/ubuntu`
63   - `sudo cp -r /mnt/cdrom/* /var/www/download/ubuntu/`
64   - `sudo cp /mnt/cdrom/ubuntu/isolinux/ldlinux.c32 /var/lib/tftpboot`
65   - `sudo cp /mnt/cdrom/ubuntu/isolinux/libcom32.c32 /var/lib/tftpboot`
66   - `sudo cp /mnt/cdrom/ubuntu/isolinux/libutil.c32 /var/lib/tftpboot`
67   - `sudo cp /mnt/cdrom/ubuntu/isolinux/chain.c32 /var/lib/tftpboot`
68   - `sudo umount /mnt/cdrom`
69   - edit ks.cfg and replace IP address with that of your PXE bootstrap server and subdir in /var/www (in this case /download)
70   - `sudo cp ks.cfg /var/www/download/ks.cfg`
71   - edit boot-screens_txt.cfg and replace IP address with that of your PXE bootstrap server and subdir in /var/www (in this case /download)
72   - `sudo cp boot-screens_txt.cfg /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg`
73   - `sudo cp syslinux.cfg /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/syslinux.cfg`
74
75 ### New testbed host - manual preparation
76
77 - set CIMC address
78 - set CIMC username, password and hostname
79
80 ### Bootstrap the host
81
82 From PXE boostrap server:
83
84   - `cd ~testuser/host-setup/cimc`
85   - Initialize args.ip: Power-Off, reset BIOS defaults, Enable console redir, get LOM MAC addr
86   - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -i`
87   - Adjust BIOS settings
88   - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -s '<biosVfIntelHyperThreadingTech rn="Intel-HyperThreading-Tech" vpIntelHyperThreadingTech="disabled" />' -s '<biosVfEnhancedIntelSpeedStepTech rn="Enhanced-Intel-SpeedStep-Tech" vpEnhancedIntelSpeedStepTech="disabled" />' -s '<biosVfIntelTurboBoostTech rn="Intel-Turbo-Boost-Tech" vpIntelTurboBoostTech="disabled" />'`
89   - add MAC address to DHCP (/etc/dhcp/dhcpd.conf)
90   - Reboot server with boot from PXE (restart immediately)
91   - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -pxe`
92
93 While Ubuntu install is running:
94
95   - create RAID array. Reboot if needed.
96       - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d --wipe`
97       - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -r -rl 1 -rs <disk size> -rd '[1,2]'`
98         Alternatively, create the RAID array manually.
99
100   - Set the next boot from HDD (without restart)
101   - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -hdd`
102
103 When installation is finished:
104
105   - `ssh-copy-id 10.30.51.x`
106   - `cd ~testuser/host-setup/playbooks`
107   - edit /etc/ansible/hosts; add the hosts you are installing. *REMOVE ANY HOSTS YOU ARE NOT CURRENTLY INSTALLING*.
108
109     Example for physical testbed hosts:
110     ~~~
111     [tg]
112     10.30.51.24 hostname=t3-tg1 isolcpus="1-17,19-35" ansible_python_interpreter=/usr/bin/python2.7
113
114     [sut]
115     10.30.51.25 hostname=t3-sut1 isolcpus="1-17,19-35" ansible_python_interpreter=/usr/bin/python2.7
116     10.30.51.26 hostname=t3-sut2 isolcpus="1-17,19-35" ansible_python_interpreter=/usr/bin/python2.7
117     ~~~
118
119     Example for VIRL hosts -- use the "virl" tag and specify the flat network start and end addresses:
120
121     ~~~
122     [virl]
123     10.30.51.28 hostname=t4-virl1 virl_l2_start=10.30.52.2 virl_l2_end=10.30.52.253 virl_l2_network=10.30.52.0/24 virl_l2_ip=10.30.52.254 virl_public_port=eth0
124     ~~~
125
126   - `ansible-playbook --ask-sudo-pass 01-host-setup.yaml`
127   - `ansible-playbook reboot.yaml`
128
129 For non-VIRL hosts, stop here.
130
131
132 ### VIRL installation
133
134 After the host has rebooted:
135
136   - `ansible-playbook 02-virl-bootstrap.yaml`
137   - ssh to host
138       - `sudo -s`
139       - `cd virl-bootstrap`
140       - `./virl-bootstrap-wrapper`
141
142         This command will error out when run the first time, as the VIRL host is not yet licensed.
143
144         Make sure we contact all three VIRL SALT masters:
145
146       - `for a in 1 2 4 ; do sudo salt-call --master us-${a}.virl.info test.ping ; done`
147
148       - Contact the VIRL team, provide the hostname and domain (linuxfoundation.org), and ask them
149         to accept the key
150
151       - After the key has been accepted, verify that connectivity with the SALT master is now OK:
152
153         `for a in 1 2 4 ; do sudo salt-call --master us-${a}.virl.info test.ping ; done`
154
155       - `./virl-bootstrap-wrapper`
156       - `reboot`
157
158 After reboot, ssh to host again
159   - as VIRL user, NOT AS ROOT:
160      - `vinstall all`
161      - `sudo reboot`
162
163 After reboot, ssh to host again
164   - as VIRL user:
165       - `sudo salt-call state.sls virl.routervms.all`
166       - `sudo salt-call state.sls virl.vmm.vmmall`
167
168 Back on the PXE bootstrap server:
169
170   - obtain the current server disk image and place it into
171     `files/virl-server-image/` as `server.qcow2`
172
173     TO-DO: Need to find a place to store this image
174
175   - `ansible-playbook 03-virl-post-install.yaml`
176
177   - Run the following command ONLY ONCE. Otherwise it will create
178     duplicates of the VIRL disk image:
179
180     `ansible-playbook 04-disk-image.yaml`
181
182 The VIRL host should now be operational. Test, and when ready, create a ~jenkins-in/status file with the appropriate status.