cloudforms, manageiq

Updating CloudForms advanced settings without a Web UI

To update the advanced settings of a CloudForms appliance you need to be logged in to the web interface of the actual appliance that needs updating. This is somewhat different to other general settings, which can be updated from any appliance or even from the appliance console.

“So what?” you ask. Well, things get complicated when you do not have access to the web interface. Perhaps it has not been enabled on one or more appliances in your cluster. Perhaps you are load balancing your web UI and are experiencing SSL certificate woes when trying to access appliance URLs. Or maybe, just maybe, you forgot to enable the Web Services role when upgrading from CloudForms 4.2 to 4.6 (CFME 5.7 => 5.9), effectively disabling authentication via the UI, like I may or may not have done…

Now before we continue, I should stress that editing these advanced settings can potentially make your system unstable or even totally disable it. Be sure you know what you are doing and of course test first!

The first thing you will need to do is SSH to your appliance and load the Ruby on Rails console, which allows you to interact with your Rails application (CloudForms!) using IRB (Interactive Ruby, basically a Ruby shell)

# cd /var/www/miq/vmdb
# rails console
Loading production environment (Rails 5.0.6)
irb(main):001:0>

Now the best thing to do is collect the existing settings. This helps to understand the data structure and type for each setting, and also what the current values are (especially helpful where settings may be concatenated, such as server roles)

> config = MiqServer.my_server.get_config.config

It is possible to replace my_server here with a lookup of other appliances based on server ID, but this is over-complicating things for now. If you are interested in digging further, check out the configure_server_settings.rb script that ships with the CloudForms tools. Using my_server works just fine assuming you are connected to the appliance you wish to update.

Next you want to output the existing settings. There are a number of options here, including a plain Ruby puts of the entire configuration on a single line, a pretty print (pp) which outputs the configuration in a more human-readable format, or a targeted output of the exact setting you wish to update. I have given examples of each below, with only partial output shown

> puts config
{:api=>{:token_ttl=>"10.minutes",...},...}
> pp config
{:api=>
  {:token_ttl=>"10.minutes",
   ...
  },
  ...
}
> puts config[:api][:token_ttl]
10.minutes

Lastly we are ready to update the setting. Be aware of different data types (i.e. integer vs string) – the output from get_config will be helpful

> MiqServer.my_server.set_config(
    {:api=>{:token_ttl=>"30.minutes"}}
)

Some settings require an evmserverd restart, some don’t. Either restart to be safe, or go ahead and test your new setting.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.