123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- # Base Install
- sudo yum install -y git
- git clone https://git.susnik.work/jan/packstack_ironic_ocata.git
- cd packstack_ironic_ocata
- sudo bash run_setup.sh ironic eno2
- # Source OpenStack credentials
- . keystonerc_admin
- NODE_HOSTNAME="baremetal"
- ironic node-create -n "$NODE_HOSTNAME" -d pxe_ipmitool -i ipmi_address='10.0.0.2' -i ipmi_username='user' -i ipmi_password='password'
- ironic node-update a378e5f9-8e44-44ae-9ba1-1f5b973a6b36 add driver_info/ipmi_protocol_version='1.5'
- ironic port-create -n a378e5f9-8e44-44ae-9ba1-1f5b973a6b36 -a 00:12:34:56:78:90
- # Check if connection to machine works
- ironic node-set-power-state baremetal on
- # Check if machine was successfully powered on
- ipmipower -h 10.0.0.2 -u root -p ironic --stat
- # When you'll be sure connection works as expected
- ironic node-set-power-state baremetal off
- # Create TFTP directory and place all required files into it
- # https://docs.openstack.org/project-install-guide/baremetal/draft/setup-drivers.html
- mkdir -p /tftpboot
- chown -R ironic /tftpboot
- yum install -y tftp-server syslinux-tftpboot xinetd
- # Edit file /etc/xinetd.d/tftp and replace it's service contents with
- service tftp
- {
- protocol = udp
- port = 69
- socket_type = dgram
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -v -v -v -v -v --map-file /tftpboot/map-file /tftpboot
- disable = no
- # This is a workaround for Fedora, where TFTP will listen only on
- # IPv6 endpoint, if IPv4 flag is not used.
- flags = IPv4
- }
- systemctl restart xinetd
- cp /usr/share/syslinux/{pxelinux.0,chain.c32} /tftpboot/
- echo 're ^(/tftpboot/) /tftpboot/\2' > /tftpboot/map-file
- echo 're ^/tftpboot/ /tftpboot/' >> /tftpboot/map-file
- echo 're ^(^/) /tftpboot/\1' >> /tftpboot/map-file
- echo 're ^([^/]) /tftpboot/\1' >> /tftpboot/map-file
- chcon -R -t tftpdir_rw_t /tftpboot
- # Enable web console - works only with IPMI 2.0
- yum install -y epel-release
- yum --enablerepo=epel install -y shellinabox
- # Uncomment following lines in /etc/ironic/ironic.conf for TFTP/PXE ...
- # my_ip = 10.0.0.1
- # tftp_server = $my_ip
- # tftp_root = /tftpboot
- # pxe_bootfile_name = pxelinux.0
- # ... and change following line to:
- # pxe_append_params = nofb nomodeset vga=normal console=tty0 console=ttyS0,115200n8
- systemctl restart openstack-ironic-conductor
- # Update node to support web console
- ironic node-update a378e5f9-8e44-44ae-9ba1-1f5b973a6b36 add driver_info/ipmi_terminal_port=8023
- ironic node-set-console-mode a378e5f9-8e44-44ae-9ba1-1f5b973a6b36 true
- # Configure Ironic
- # https://docs.openstack.org/developer/openstack-ansible-os_ironic/ocata/configure-ironic.html
- neutron net-create ironic-net --shared --provider:network_type flat --provider:physical_network physnet1
- neutron subnet-create ironic-net 10.1.2.176/28 --name ironic-subnet --ip-version=4 --allocation-pool start=10.1.2.178,end=10.1.2.190 --gateway 10.1.2.1 --enable-dhcp --dns-nameservers list=true 8.8.4.4 8.8.8.8
- # Change /etc/neutron/plugins/ml2/ml2_conf.ini to ...
- # [ml2_type_vlan]
- # network_vlan_ranges = physnet1
- systemctl restart neutron-{openvswitch-agent,server}
- # We also need to update cleaning network in /etc/ironic/ironic.conf now
- # cleaning_network = ironic-net
- systemctl restart openstack-ironic-conductor
- # https://docs.openstack.org/developer/diskimage-builder/user_guide/installation.html
- yum install -y python-pip
- pip install --upgrade pip
- pip install diskimage-builder
- # Generate disk image for booting on node
- IMAGE_NAME="fedora"
- mkdir "$IMAGE_NAME" && cd "$IMAGE_NAME"
- disk-image-create fedora iso -o "$IMAGE_NAME" ironic-agent
- glance image-create --name "${IMAGE_NAME}.kernel" --visibility public --disk-format aki --property hypervisor_type=baremetal --protected=True --container-format aki < "${IMAGE_NAME}.kernel"
- glance image-create --name "${IMAGE_NAME}.initramfs" --visibility public --disk-format ari --property hypervisor_type=baremetal --protected=True --container-format ari < "${IMAGE_NAME}.initramfs"
- IMAGE_SOURCE=$(openstack image create "$IMAGE_NAME" --public --disk-format=iso --container-format=bare < "${IMAGE_NAME}.iso" -f value -c id)
- # Create flavor
- FLAVOR_NAME="$IMAGE_NAME"
- FLAVOR_ID=auto
- FLAVOR_RAM=8192
- FLAVOR_DISK=230
- FLAVOR_CPU=4
- nova flavor-create ${FLAVOR_NAME} ${FLAVOR_ID} ${FLAVOR_RAM} ${FLAVOR_DISK} ${FLAVOR_CPU}
- nova flavor-key ${FLAVOR_NAME} set cpu_arch=x86_64
- nova flavor-key ${FLAVOR_NAME} set capabilities:boot_option="local"
- # Update node info
- KERNEL_IMAGE=$(glance image-list | awk "/${IMAGE_NAME}.kernel/ {print \$2}")
- INITRAMFS_IMAGE=$(glance image-list | awk "/${IMAGE_NAME}.initramfs/ {print \$2}")
- ROOT_DISK_SIZE_GB="$FLAVOR_DISK"
- ironic node-update "$NODE_HOSTNAME" add \
- driver_info/deploy_kernel=$KERNEL_IMAGE \
- driver_info/deploy_ramdisk=$INITRAMFS_IMAGE \
- instance_info/kernel=$KERNEL_IMAGE \
- instance_info/ramdisk=$INITRAMFS_IMAGE \
- instance_info/root_gb=${ROOT_DISK_SIZE_GB} \
- instance_info/image_source=${IMAGE_SOURCE}
- ironic node-update "$NODE_HOSTNAME" add \
- properties/cpus="$FLAVOR_CPU" \
- properties/memory_mb="$FLAVOR_RAM" \
- properties/local_gb="$ROOT_DISK_SIZE_GB" \
- properties/size=3600 \
- properties/cpu_arch=x86_64 \
- properties/capabilities=memory_mb:"$FLAVOR_RAM",local_gb:"$ROOT_DISK_SIZE_GB",cpu_arch:x86_64,cpus:"$FLAVOR_CPU",boot_option:local
- # Add SSH keypair
- nova keypair-add --pub-key ~/.ssh/id_rsa.pub admin
- # Check if keystone authentication config in /etc/nova/nova.conf is correct or change part with all values below (those values are usually already written at the end of config block, but are most probably wrong - that's why openstack-nova-compute service is inactive)
- # [ironic]
- # username=ironic
- # password=<ironic-password>
- # auth_plugin=password
- # admin_username=ironic
- # admin_password=<ironic-password>
- # admin_url=http://127.0.0.1:35357/
- # admin_tenant_name=services
- # Restart Nova Compute to apply changed config
- systemctl restart openstack-nova-compute
- # Make sure we have available hosts
- nova-manage cell_v2 discover_hosts
- # Make services available to Ironic network
- iptables -I INPUT -p udp --dport 67 -s 10.1.2.0/24 -j ACCEPT
- iptables -I INPUT -p udp --dport 69 -s 10.1.2.0/24 -j ACCEPT
- iptables -I INPUT -p tcp --dport 3260 -s 10.1.2.0/24 -j ACCEPT
- service iptables save
- service iptables restart
- # Boot node with generated image
- nova boot --flavor "$FLAVOR_NAME" --image "$IMAGE_NAME" --key-name admin "$NODE_HOSTNAME" --nic net-name=ironic-net
- # (Warning: Don't perform this step until you tried to boot node!) In case that status of node is Error, we need to change RAM allocation value to a bit more then currently (usually this is 1.0), so we open /etc/nova/nova.conf and set
- # ram_allocation_ratio=3.0
- # And restart Nova Compute & Nova Conductor to apply changes
- systemctl restart openstack-nova-{compute,conductor}
- #############################
- #echo 'linux-image-generic-lts-xenial:' > /usr/share/diskimage-builder/elements/ubuntu/package-installs.yaml
- echo 'linux-image-generic-lts-xenial:' > /usr/lib/python2.7/site-packages/diskimage_builder/elements/ubuntu/package-installs.yaml
- IMAGE_NAME=ubuntu-xenial
- disk-image-create ironic-agent ubuntu -o ${IMAGE_NAME}
- glance image-create --name ${IMAGE_NAME}.kernel --visibility public --disk-format aki --container-format aki < ${IMAGE_NAME}.kernel
- glance image-create --name ${IMAGE_NAME}.initramfs --visibility public --disk-format ari --container-format ari < ${IMAGE_NAME}.initramfs
- pip install tripleo-image-elements
- export ELEMENTS_PATH=/usr/share/tripleo-image-elements
- disk-image-create ubuntu baremetal localboot local-config dhcp-all-interfaces grub2 -o ${IMAGE_NAME}
- VMLINUZ_UUID="$(glance image-create --name ${IMAGE_NAME}.vmlinuz --visibility public --disk-format aki --container-format aki < ${IMAGE_NAME}.vmlinuz | awk '/\| id/ {print $4}')"
- INITRD_UUID="$(glance image-create --name ${IMAGE_NAME}.initrd --visibility public --disk-format ari --container-format ari < ${IMAGE_NAME}.initrd | awk '/\| id/ {print $4}')"
- glance image-create --name ${IMAGE_NAME} --visibility public --disk-format qcow2 --container-format bare --property kernel_id=${VMLINUZ_UUID} --property ramdisk_id=${INITRD_UUID} < ${IMAGE_NAME}.qcow2
- FLAVOR_NAME="$IMAGE_NAME"
- FLAVOR_ID=auto
- FLAVOR_RAM=1512
- FLAVOR_DISK=5
- FLAVOR_CPU=1
- nova flavor-create ${FLAVOR_NAME} ${FLAVOR_ID} ${FLAVOR_RAM} ${FLAVOR_DISK} ${FLAVOR_CPU}
- nova flavor-key ${FLAVOR_NAME} set cpu_arch=x86_64
- nova flavor-key ${FLAVOR_NAME} set capabilities:boot_option="local"
- NODE_HOSTNAME="baremetal"
- KERNEL_IMAGE=$(glance image-list | awk "/${IMAGE_NAME}.kernel/ {print \$2}")
- INITRAMFS_IMAGE=$(glance image-list | awk "/${IMAGE_NAME}.initramfs/ {print \$2}")
- ROOT_DISK_SIZE_GB="$FLAVOR_DISK"
- ironic node-update "$NODE_HOSTNAME" add \
- driver_info/kernel=$KERNEL_IMAGE \
- driver_info/ramdisk=$INITRAMFS_IMAGE \
- instance_info/kernel=$KERNEL_IMAGE \
- instance_info/ramdisk=$INITRAMFS_IMAGE \
- instance_info/root_gb=${ROOT_DISK_SIZE_GB} \
- instance_info/image_source=${IMAGE_NAME}
- ironic node-update "$NODE_HOSTNAME" add \
- properties/cpus="$FLAVOR_CPU" \
- properties/memory_mb="$FLAVOR_RAM" \
- properties/local_gb="$ROOT_DISK_SIZE_GB" \
- properties/size=3600 \
- properties/cpu_arch=x86_64 \
- properties/capabilities=memory_mb:"$FLAVOR_RAM",local_gb:"$ROOT_DISK_SIZE_GB",cpu_arch:x86_64,cpus:"$FLAVOR_CPU",boot_option:local
- nova keypair-add --pub-key ~/.ssh/id_rsa.pub admin
- # change username & password + ram allocation to 3.0 for [ironic] in /etc/nova/nova.conf
- nova-manage cell_v2 discover_hosts
- chcon -R -t tftpdir_rw_t /tftpboot
- iptables -I INPUT -p udp --dport 67 -s 10.1.2.0/24 -j ACCEPT
- iptables -I INPUT -p udp --dport 69 -s 10.1.2.0/24 -j ACCEPT
- iptables -I INPUT -p tcp --dport 3260 -s 10.1.2.0/24 -j ACCEPT
- service iptables save
- service iptables restart
- # nova compute install + systemctl enable openstack-nova-compute + api in nova/nova.conf for ironic, cleaning net ironic, chcon /tftpboot, iptables dhcp + tftp
- nova boot --flavor ${FLAVOR_NAME} --image ${IMAGE_NAME} --key-name admin ${NODE_HOSTNAME} --nic net-name=ironic-net
- # nova boot --flavor ubuntu-xenial --image ubuntu-xenial --key-name admin baremetal --nic net-name=ironic-net
- # dnsmasq with --no-daemon && without bind-interfaces
|