Skip to content

Instantly share code, notes, and snippets.

@mtaylor
Created March 20, 2014 15:03
Show Gist options
  • Save mtaylor/9665802 to your computer and use it in GitHub Desktop.
Save mtaylor/9665802 to your computer and use it in GitHub Desktop.
User.current = User.first
##
# Change the name to Hostgroup on your existing machine
##
base_hostgroup = Hostgroup.where(:name => "default").first_or_create!
deployment = Staypuft::Deployment.where(:name => "My Openstack Deployment").first_or_initialize
deployment.description = "This is a deployment"
deployment.layout = Staypuft::Layout.where(:name => "Distributed",
:networking => "neutron").first
deployment_hostgroup = Hostgroup.where(:name =>"My Openstack Deployment").first_or_initialize
deployment_hostgroup.parent_id = base_hostgroup.id
deployment_hostgroup.save!
deployment.hostgroup = deployment_hostgroup
deployment.save!
deployment.layout.roles.each do |role|
role_hostgroup = Hostgroup.where(:name =>"#{deployment.name}: #{role.name}").first_or_initialize
role_hostgroup.parent_id = deployment_hostgroup.parent_id
unless role_hostgroup.puppetclasses.include?(role.puppetclasses.first)
role_hostgroup.puppetclasses << role.puppetclasses.first
end
role_hostgroup.save!
Staypuft::DeploymentRoleHostgroup.where(:deployment_id => deployment.id, :hostgroup_id => role_hostgroup.id).first_or_create!
Staypuft::HostgroupRole.where(:role_id => role.id, :hostgroup_id => role_hostgroup.id).first_or_create!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment