Update Ansible scripts
[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 when there is no http server AMD64
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   - `sudo mkdir /mnt/cdrom`
35   - Ubuntu Xenial
36     - `wget 'http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-server-amd64.iso'`
37     - `sudo mount -o loop ubuntu-16.04.2-server-amd64.iso /mnt/cdrom/`
38   - Ubuntu Bionic
39     - `wget 'http://cdimage.ubuntu.com/ubuntu/releases/18.04/release/ubuntu-18.04-server-amd64.iso'`
40     - `sudo mount -o loop ubuntu-18.04-server-amd64.iso /mnt/cdrom/`
41   - `sudo cp -r /mnt/cdrom/install/netboot/* /var/lib/tftpboot/`
42   - figure out where nginx will look for files on the filesystem when
43     responding to HTTP requests. The configuration is in one of the
44     files in /etc/nginx/conf.d/, /etc/nginx/sites-enabled/ or in
45     /etc/nginx/nginx.conf under section server/root. Save the path to WWW_ROOT
46   - `sudo mkdir -p ${WWW_ROOT}/download/ubuntu`
47   - `sudo cp -r /mnt/cdrom/* ${WWW_ROOT}/download/ubuntu/`
48   - `sudo cp /mnt/cdrom/ubuntu/isolinux/ldlinux.c32 /var/lib/tftpboot`
49   - `sudo cp /mnt/cdrom/ubuntu/isolinux/libcom32.c32 /var/lib/tftpboot`
50   - `sudo cp /mnt/cdrom/ubuntu/isolinux/libutil.c32 /var/lib/tftpboot`
51   - `sudo cp /mnt/cdrom/ubuntu/isolinux/chain.c32 /var/lib/tftpboot`
52   - `sudo umount /mnt/cdrom`
53   - edit ks.cfg and replace IP address with that of your PXE bootstrap server and subdir in /var/www (in this case /download)
54   - `sudo cp ks.cfg ${WWW_ROOT}/download/ks.cfg`
55   - 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)
56   - `sudo cp boot-screens_txt.cfg /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg`
57   - `sudo cp syslinux.cfg /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/syslinux.cfg`
58
59 ### New testbed host - manual preparation
60
61 - set CIMC address
62 - set CIMC username, password and hostname
63 - set IPMI address
64 - set IPMI username, password and hostname
65
66 ### Bootstrap the host
67
68 Optional: From PXE boostrap server in case of installing Haswell
69
70   - `cd resources/tools/testbed-setup/cimc`
71   - Initialize args.ip: Power-Off, reset BIOS defaults, Enable console redir, get LOM MAC addr
72   - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -i`
73   - Adjust BIOS settings
74   - `./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" />'`
75   - add MAC address to DHCP (/etc/dhcp/dhcpd.conf)
76   - Reboot server with boot from PXE (restart immediately)
77   - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -pxe`
78
79 Optional: If RAID is not created on Haswells. Execute while Ubuntu install is running
80
81   - create RAID array. Reboot if needed.
82       - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d --wipe`
83       - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -r -rl 1 -rs <disk size> -rd '[1,2]'`
84         Alternatively, create the RAID array manually.
85
86   - Set the next boot from HDD (without restart)
87   - `./cimc.py -u admin -p Cisco1234 $CIMC_ADDRESS -d -hdd`
88
89 Optional: If installing Skylake machine
90
91     - Get MAC address of LAN0
92     - `ipmitool -U ADMIN -H $HOST_ADDRESS raw 0x30 0x21 | tail -c 18`
93     - Reboot into PXE for next boot only
94     - `ipmitool -I lanplus -H $HOST_ADDRESS -U ADMIN chassis bootdev pxe`
95     - `ipmitool -I lanplus -H $HOST_ADDRESS -U ADMIN power reset`
96     - For live watching SOL (Serial-over-LAN console)
97     - `ipmitool -I lanplus -H $HOST_ADDRESS -U ADMIN sol activate`
98     - `ipmitool -I lanplus -H $HOST_ADDRESS -U ADMIN sol deactivate`
99
100
101 When installation is finished:
102
103   - Copy ssh keys for no pass access: `ssh-copy-id 10.30.51.x`
104   - Clone CSIT actual repo: `git clone https://gerrit.fd.io/r/csit`
105   - Go to ansible directory: `cd csit/resources/tools/testbed-setup/ansible`
106   - Edit production file and uncomment servers that are supposed to be installed: `ansible-playbook --ask-become-pass --inventory production site.yaml --list-hosts`
107   - Run ansible on selected hosts: `ansible-playbook --vault-id vault_pass --extra-vars '@vault.yml' --inventory production site.yaml`
108
109 For non-VIRL hosts, stop here.
110
111 ### VIRL installation
112
113 After the host has rebooted:
114
115   - `ansible-playbook 02-virl-bootstrap.yaml`
116   - ssh to host
117       - `sudo -s`
118       - `cd virl-bootstrap`
119       - `./virl-bootstrap-wrapper`
120
121         This command will error out when run the first time, as the VIRL host is not yet licensed.
122
123         Make sure we contact all three VIRL SALT masters:
124
125       - `for a in 1 2 4 ; do sudo salt-call --master us-${a}.virl.info test.ping ; done`
126
127       - Contact the VIRL team, provide the hostname and domain (linuxfoundation.org), and ask them
128         to accept the key
129
130       - After the key has been accepted, verify that connectivity with the SALT master is now OK:
131
132         `for a in 1 2 4 ; do sudo salt-call --master us-${a}.virl.info test.ping ; done`
133
134       - `./virl-bootstrap-wrapper`
135       - `reboot`
136
137 After reboot, ssh to host again
138   - as VIRL user, NOT AS ROOT:
139      - `vinstall all`
140      - `sudo reboot`
141
142 After reboot, ssh to host again
143   - as VIRL user:
144       - `sudo salt-call state.sls virl.routervms.all`
145       - `sudo salt-call state.sls virl.vmm.vmmall`
146
147 Back on the PXE bootstrap server:
148
149   - obtain the current server disk image and place it into
150     `files/virl-server-image/` as `server.qcow2`
151
152     TO-DO: Need to find a place to store this image
153
154   - `ansible-playbook 03-virl-post-install.yaml`
155
156   - Run the following command ONLY ONCE. Otherwise it will create
157     duplicates of the VIRL disk image:
158
159     `ansible-playbook 04-disk-image.yaml`
160
161 The VIRL host should now be operational. Test, and when ready, create a ~jenkins-in/status file with the appropriate status.