Created
December 9, 2016 19:56
-
-
Save jpadams/a99e0c8c108dc53185d1bedf1beef584 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'json' | |
| require 'tempfile' | |
| fact_to_change = ARGV.shift | |
| new_value = ARGV.shift | |
| vra_facts_file_path = "/etc/puppetlabs/facter/facts.d/puppet_vra_facts.json" | |
| vra_facts = JSON.parse(%x(/opt/puppetlabs/bin/facter puppet_vra_properties -j)) | |
| vra_prop = "Puppet.VRA.Prop.#{fact_to_change}" | |
| vra_facts["puppet_vra_properties"][vra_prop] = new_value | |
| file = Tempfile.new('vra_facts') | |
| file.write(vra_facts.to_json) | |
| file.close | |
| %x(cp #{file.path} #{vra_facts_file_path}) | |
| file.unlink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment