Set up user data ISO for cloud init. The VM can be initialized with openstack config drive version 2 formatted data. Cloud
init expects a specific directory layout. Refer to the following recommended cloud init configuration:
Directory Layout:
Top level directory --> config-drive/
└── openstack/
├── content/
| └── 0000
└── latest/
├── meta_data.json
└── user_data
A forward slash (‘/’) at the end of the line indicates a directory.
Description of the files and example content:
meta_data.json:
{
"files": [
{
"content_path": "/content/0000",
"path": "/etc/network/interfaces"
}
],
"hostname": "cps-tsi-updater",
"launch_index": 0,
"name": "cps-master",
"meta": {
"dsmode": "local"
},
"uuid": "cps-master"
}
hostname, name and uuid can be modified as required.
user_data:
#cloud-config
debug: True
output: {all: '| tee -a /var/log/cloud-init-output.log'}
users:
- name: cps
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: docker
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDzjJjndIvUiBta4VSIbd2gJmlMWcQ8wtejgAbiXtoFZdtMdo9G0ZDEOtxHNNDPwWujMiYA
kZhZWX/zON9raavU8lgD9+YcRopWUtujIC71YjtoxIjWIBBbrtqtPlUXMUXQsi91RQbUtslENP+tSatS3awoQupyBMMSutyBady/7Wq0UTwFsnYs5Jfs
8jIQuMfVQ9uJ4mNn7wJ0N+Iaf27rE0t3oiY5DRN6j07WhauM6lCnZ1JDlzqmTnTHQkgJ3uKmQa5x73tJ1OW89Whf+R+dfslVn/yUwK/vf4extHTn32Dt
sxkjz7kQeEDgCe/y7owimaEFcCIfEWEaj/50jegN cps@root-public-key
chpasswd:
list: |
cps: cisco123
expire: False
write_files:
- path: /home/cps/.bash_aliases
encoding: text/plain
content: |
alias cli="ssh -p 2024 admin@localhost"
owner: cps:cps
permissions: '0644'
- path: /root/swarm.json
content: |
{
"role": "master",
"identifier": "master-0",
"master": "172.16.2.99",
"network": "172.16.2.0/24",
"registry": "172.16.2.99:5000",
"reinitialize_data": "1",
"zing": "1",
"tenant": "tsi",
"weavePw": "cisco123",
"scheduler": "aio",
"deployment_name": "cps-tsi",
"init": "cisco-mitg-tsi/init"
}
owner: root:root
permissions: '0644'
- path: /etc/update-motd.d/20-cps-text
content: |
#!/bin/sh
product=`jq ".product" /root/swarm.json | tr -d '"'`
identifier=`jq ".identifier" /root/swarm.json | tr -d '"'`
printf "\n"
printf " * CPS Microservices - ${product}\n"
printf " * CPS Docker Engine - ${identifier}\n"
printf "\n"
owner: root:root
permissions: '0755'
The “chpasswd:” directive specifies that a user named “cps” be created with password “cisco123”. Replace with a secure password.
The user is set up with sudo access; this is helpful when collecting various troubleshooting information. The SSH key facilitates
password-less login; this will need to be generated anew.
The IP 172.16.2.x IP addresses specified under swarm.json refer to the internal network, so edit as appropriate:
-
“master:” value should be the IP address assigned to the VM on the internal network
-
“network:” value should be the CIDR of the internal network
-
“registry:” value should be the <server IP>:5000
bash_aliases file is optional. It provides a convenience alias to access the CLI once logged into the VM.
Replace weavePw value in swarm.json with a secure password
All other values should be left as is.
0000:
auto lo
iface lo inet loopback
auto ens160
iface ens160 inet static
address 172.18.45.99
netmask 255.255.255.0
gateway 172.18.45.1
auto ens192
iface ens192 inet static
address 172.16.2.99
netmask 255.255.255.0
auto ens224
iface ens224 inet static
address 172.18.53.142
netmask 255.255.255.0
As meta_data.json indicates, contents of content/0000 populate /etc/network/interfaces file on the VM. The example configures
3 networks, an internal network (ens192), one for communication with StarOS gateways (ens224), and one for internet access
(ens160).