Announcing Spiceweasel

Yesterday I released a new CLI tool for generating knife commands from
simple YAML describing your Chef-managed infrastructure. It’s on
GitHub (http://bit.ly/spcwsl) and RubyGems (gem install spiceweasel)
if you’re interested. The YAML syntax is very simple, but this isn’t
intended to be anything more than a simple-batchloader. Eventually it
will support deleting and rebuilding the YAML-described infrastructure
as well as re-running chef-client on each listed node.

The YAML file:

cookbooks:

  • apache2
  • apt
  • mysql
    roles:
  • base
  • monitoring
  • webserver
    data bags:
    users:
    • alice
    • bob
    • chuck
      data:
      nodes:
      serverA:
    • role[loadbalancer]
    • -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
      ec2 5:
    • role[webserver]
    • -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd
      -f m1.small
      rackspace 3:
    • recipe[mysql] role[clustered_mysql]
    • –image 49 --flavor 2

turns into

knife cookbook upload apache2
knife cookbook upload apt
knife cookbook upload mysql
knife role from file base.rb
knife role from file monitoring.rb
knife role from file webserver.rb
knife data bag create data
knife data bag create users
knife data bag from file users data_bags/alice.json
knife data bag from file users data_bags/bob.json
knife data bag from file users data_bags/chuck.json
knife bootstrap serverA ‘role[loadbalancer]’ -i ~/.ssh/mray.pem -x
user --sudo -d ubuntu10.04-gems
knife ec2 server create ‘role[webserver]’ -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create ‘role[webserver]’ -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create ‘role[webserver]’ -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create ‘role[webserver]’ -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create ‘role[webserver]’ -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife rackspace server create ‘recipe[mysql]’ ‘role[clustered_mysql]’
–image 49 --flavor 2
knife rackspace server create ‘recipe[mysql]’ ‘role[clustered_mysql]’
–image 49 --flavor 2
knife rackspace server create ‘recipe[mysql]’ ‘role[clustered_mysql]’
–image 49 --flavor 2

Feedback is appreciated!

Thanks,
Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray

Instead of using yaml why not just call knife from a rake script? You
could use filelists to describe the things to upload or even use knife
at the library level to speed things up.

On Sat, Mar 5, 2011 at 10:44 AM, Matt Ray matt@opscode.com wrote:

Yesterday I released a new CLI tool for generating knife commands from
simple YAML describing your Chef-managed infrastructure. It's on
GitHub (GitHub - mattray/spiceweasel: Generates Chef knife commands from a simple JSON or YAML file.) and RubyGems (gem install spiceweasel)
if you're interested. The YAML syntax is very simple, but this isn't
intended to be anything more than a simple-batchloader. Eventually it
will support deleting and rebuilding the YAML-described infrastructure
as well as re-running chef-client on each listed node.

The YAML file:

cookbooks:

  • apache2
  • apt
  • mysql
    roles:
  • base
  • monitoring
  • webserver
    data bags:
    users:
    • alice
    • bob
    • chuck
      data:
      nodes:
      serverA:
    • role[loadbalancer]
    • -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
      ec2 5:
    • role[webserver]
    • -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd
      -f m1.small
      rackspace 3:
    • recipe[mysql] role[clustered_mysql]
    • --image 49 --flavor 2

turns into

knife cookbook upload apache2
knife cookbook upload apt
knife cookbook upload mysql
knife role from file base.rb
knife role from file monitoring.rb
knife role from file webserver.rb
knife data bag create data
knife data bag create users
knife data bag from file users data_bags/alice.json
knife data bag from file users data_bags/bob.json
knife data bag from file users data_bags/chuck.json
knife bootstrap serverA 'role[loadbalancer]' -i ~/.ssh/mray.pem -x
user --sudo -d ubuntu10.04-gems
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]'
--image 49 --flavor 2
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]'
--image 49 --flavor 2
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]'
--image 49 --flavor 2

Feedback is appreciated!

Thanks,
Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray

Rake would probably work for some cases, but wanted a simple way to
pass around descriptions of infrastructure so you use the YAML file in
a repo with hundreds of cookbooks and roles, but load only use the
exact ones you use. It also adds the nodes in order, so you could
ensure each dependency is already in place as you create your nodes
(eg. webservers before load balancers). 0.2 is almost ready, adding
deletion and rebuilding support. Eventually I will probably make the
API calls directly when you use the "--execute" flag.

Thanks,
Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray

On Sat, Mar 5, 2011 at 7:56 PM, Michael Hale mikehale@gmail.com wrote:

Instead of using yaml why not just call knife from a rake script? You
could use filelists to describe the things to upload or even use knife
at the library level to speed things up.

On Sat, Mar 5, 2011 at 10:44 AM, Matt Ray matt@opscode.com wrote:

Yesterday I released a new CLI tool for generating knife commands from
simple YAML describing your Chef-managed infrastructure. It's on
GitHub (GitHub - mattray/spiceweasel: Generates Chef knife commands from a simple JSON or YAML file.) and RubyGems (gem install spiceweasel)
if you're interested. The YAML syntax is very simple, but this isn't
intended to be anything more than a simple-batchloader. Eventually it
will support deleting and rebuilding the YAML-described infrastructure
as well as re-running chef-client on each listed node.

The YAML file:

cookbooks:

  • apache2
  • apt
  • mysql
    roles:
  • base
  • monitoring
  • webserver
    data bags:
    users:
    • alice
    • bob
    • chuck
      data:
      nodes:
      serverA:
    • role[loadbalancer]
    • -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
      ec2 5:
    • role[webserver]
    • -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd
      -f m1.small
      rackspace 3:
    • recipe[mysql] role[clustered_mysql]
    • --image 49 --flavor 2

turns into

knife cookbook upload apache2
knife cookbook upload apt
knife cookbook upload mysql
knife role from file base.rb
knife role from file monitoring.rb
knife role from file webserver.rb
knife data bag create data
knife data bag create users
knife data bag from file users data_bags/alice.json
knife data bag from file users data_bags/bob.json
knife data bag from file users data_bags/chuck.json
knife bootstrap serverA 'role[loadbalancer]' -i ~/.ssh/mray.pem -x
user --sudo -d ubuntu10.04-gems
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem
-x ubuntu -G default -i ami-a403f7cd -f m1.small
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]'
--image 49 --flavor 2
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]'
--image 49 --flavor 2
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]'
--image 49 --flavor 2

Feedback is appreciated!

Thanks,
Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray