kxr / ocp4_setup_upi_kvm

Script to Setup an OpenShift 4 UPI Cluster on KVM. Based on this guide: https://kxr.me/2019/08/17/openshift-4-upi-install-libvirt-kvm/
52 stars 57 forks source link

provide option to configure VMs to autostart on boot. #13

Closed jmazzitelli closed 4 years ago

jmazzitelli commented 4 years ago

fixes https://github.com/kxr/ocp4_setup_upi_kvm/issues/8

This provides a script that can configure the cluster VMs so they will autostart at host boot time. If you already have them configured for autostart, the script can be told to turn that off (i.e. it configures the VMs so they do not autostart).

This also adds a new option to the main ocp4 install script : --autostart-cluster. When you pass that option to the install script, the VMs will be configured to autostart at boot time (but this reconfiguration will only happen after everything is installed successfully - we do not want to have the VMs autostart at boot if we are not sure the cluster was successfully installed).

Here's what the --help looks like for the new script

$ config_vm_autostart.sh -h

Usage: ./.config_vm_autostart.sh [OPTIONS]

OPTION                DESCRIPTION

-a, --autostart FLAG  Determines if you want the VMs to autostart on host reboot.
                      Valid options are "true" and "false"
                      <REQUIRED>

-y, --yes             Set this for the script to be non-interactive and continue with out asking for confirmation
                      Default: <not set>

Here's what the output looks like if you do not yet have the VMs configured for autostart, but you want them to autostart:

$ sudo config_vm_autostart.sh -a true
Will configure VMs to autostart at boot time : ocp4-lb,ocp4-master-1,ocp4-master-2,ocp4-master-3

Press enter to continue
Configuring VM: ocp4-lb ... ok
Configuring VM: ocp4-master-1 ... ok
Configuring VM: ocp4-master-2 ... ok
Configuring VM: ocp4-master-3 ... ok

Note you can pass --yes for non-interactive mode - here I turn off the autostart flag, too:

$ sudo config_vm_autostart.sh -a false -y
Will configure VMs to NOT autostart at boot time : ocp4-lb,ocp4-master-1,ocp4-master-2,ocp4-master-3
Configuring VM: ocp4-lb ... ok
Configuring VM: ocp4-master-1 ... ok
Configuring VM: ocp4-master-2 ... ok
Configuring VM: ocp4-master-3 ... ok

If you ask to configure the VMs to autostart but they are already configured for that (and vice-versa, if you ask to configure them to NOT autostart but they are already configured for that), this is the output:

$ sudo config_vm_autostart.sh -a false
No VMs to configure
jmazzitelli commented 4 years ago

@kxr what is the status of this PR? Will it be able to get merged?

kxr commented 4 years ago

@jmazzitelli Sorry, I got busy. I will review this hopefully this week.

kxr commented 4 years ago

@jmazzitelli I have looked into and it and gave it some thought. I really appreciate you efforts, however, in my humble opinion this is making it way too complicated than it should be. Setting or un-setting the vms to autostart is just a matter of running a single command. I have added a new section in the README, see 215ad47. What do you think?

jmazzitelli commented 4 years ago

Up to you. I forked this project and have it in my own fork, so it works for me. I don't want to have to remember to flip this flag to turn all my VMs to autostart after I re-install a new cluster.

kxr commented 4 years ago

@jmazzitelli You have a point that I was not considering. i.e, If you want your to cluster vms to be autostarted by default instead of setting them manually afterwards. I will add this option in the main script. Thanks a lot.

kxr commented 4 years ago

@jmazzitelli Done and tested: be3a869

jmazzitelli commented 4 years ago

closing... option added in another commit