Approaches to automate execution of Knife command


#1

Hi all,

I am using chef to provision a VM using Knife-Vcloud and i have several knife
commands to run as a sequence. I can write a Shell script to execute commands
in order but i would like to know is there a better way of automating running
of knife commands.
The requirement is as follows - When i run the 1st chef command, it provisions
a virtual machine. In my second knife command, i may use it as an input for the
command such as the IP address of the virtual machine generated in the 1st
command. Can anyone suggest a good way to do this ?


#2

Hi,

On 6 July 2014 04:58, aswin88us@gmail.com wrote:

Hi all,

I am using chef to provision a VM using Knife-Vcloud and i have several knife
commands to run as a sequence.

Why is a sequence required? What are you actually trying to do?

The requirement is as follows - When i run the 1st chef command, it provisions
a virtual machine. In my second knife command, i may use it as an input for the
command such as the IP address of the virtual machine generated in the 1st
command.

Well obviously you could do this very primitively in Ruby, but if you
really have a need to launch machines in a certain order, using
information from previous machines, you might be better using the
vcloud-rest bindings to build you infrastructure and then bootstrap
them. It would really help, though, if you could give us an idea of
the actual problem you’re trying to solve, rather than a piece of your
proposed implementation - people might already have solved it!

S.

Stephen Nelson-Smith,
Founder, Principal Consultant,
Atalanta Systems Ltd,
Web: http://agilesysadmin.net
Twitter: @lordcope
Skype: atalanta.systems
Direct: +44 (0) 1329 550203
Mobile: +44 (0) 7917 101919

Atalanta Systems: The Agile Infrastructure Enablers
http://atalanta-systems.com


#3

Hi,
we wrote (thanks to @astratto awsome job) knife-vcloud (that one based on
vcloud-rest) in order to automate our private cloud.
We are currently using Rundeck to setup and manage different kind of
wokflows that we use both directly on Rundeck and from a rails custom
webapp that uses rundeck apis (still not ready for production).
I really suggest using Rundeck if you already haven’t an alternative
solution, it is a great tool, we are very satisfied.
Marco
Il 06/lug/2014 05:58 aswin88us@gmail.com ha scritto:

Hi all,

I am using chef to provision a VM using Knife-Vcloud and i have several
knife
commands to run as a sequence. I can write a Shell script to execute
commands
in order but i would like to know is there a better way of automating
running
of knife commands.
The requirement is as follows - When i run the 1st chef command, it
provisions
a virtual machine. In my second knife command, i may use it as an input
for the
command such as the IP address of the virtual machine generated in the 1st
command. Can anyone suggest a good way to do this ?


#4

Hey hi,

Thanks for the comment. This is the actual problem i am trying to solve. I
have several web application (wars) deployed in server. In a scenario when
the web application1’s load is high, we need to subscribe one instance of
VM(using knife-vsphere plugin), bootstrap chef and run the cookbooks. This
IP address should again be added to nginx server for load balancing. So to
be brief, i need to provision one VM on the fly and run the cookbooks and i
need to use the IP address of the new VM to the next knife command.

Thanks

On Sun, Jul 6, 2014 at 3:21 AM, Marco Betti m.betti@gmail.com wrote:

Hi,
we wrote (thanks to @astratto awsome job) knife-vcloud (that one based on
vcloud-rest) in order to automate our private cloud.
We are currently using Rundeck to setup and manage different kind of
wokflows that we use both directly on Rundeck and from a rails custom
webapp that uses rundeck apis (still not ready for production).
I really suggest using Rundeck if you already haven’t an alternative
solution, it is a great tool, we are very satisfied.
Marco
Il 06/lug/2014 05:58 aswin88us@gmail.com ha scritto:

Hi all,

I am using chef to provision a VM using Knife-Vcloud and i have several
knife
commands to run as a sequence. I can write a Shell script to execute
commands
in order but i would like to know is there a better way of automating
running
of knife commands.
The requirement is as follows - When i run the 1st chef command, it
provisions
a virtual machine. In my second knife command, i may use it as an input
for the
command such as the IP address of the virtual machine generated in the 1st
command. Can anyone suggest a good way to do this ?


#5

Hi again,

On 6 July 2014 18:11, Karthik Jayaraman aswin88us@gmail.com wrote:

In a scenario when
the web application1’s load is high, we need to subscribe one instance of
VM(using knife-vsphere plugin), bootstrap chef and run the cookbooks. This
IP address should again be added to nginx server for load balancing.

So it seems like you want to be able to capture the ip address of the
new machine, and add this to the load balancer pool? If I understand
you correctly, you can achieve this easily using search with a Chef
server. In your loadbalancer recipe you search for machines which
function as Java app servers, and take the IP address (which ohai
knows), and use it in the template which renders your nginx config.

If you’re not using a Chef server, you need to think about other ways
to make this information available - for example some kind of service
discovery system such as zookeeper could be used.

Hope that helps a little.

S.


#6

Just saw chef-metal - which allows description of whole infrastructures rather than just single boxes - http://m.youtube.com/watch?v=Yb8QdL30WgM - it has drivers for vagrant and fog.

Best, M.
Sent from my iPhone

On Jul 6, 2014, at 2:12 PM, Stephen Nelson-Smith stephen@atalanta-systems.com wrote:

Hi again,

On 6 July 2014 18:11, Karthik Jayaraman aswin88us@gmail.com wrote:

In a scenario when
the web application1’s load is high, we need to subscribe one instance of
VM(using knife-vsphere plugin), bootstrap chef and run the cookbooks. This
IP address should again be added to nginx server for load balancing.

So it seems like you want to be able to capture the ip address of the
new machine, and add this to the load balancer pool? If I understand
you correctly, you can achieve this easily using search with a Chef
server. In your loadbalancer recipe you search for machines which
function as Java app servers, and take the IP address (which ohai
knows), and use it in the template which renders your nginx config.

If you’re not using a Chef server, you need to think about other ways
to make this information available - for example some kind of service
discovery system such as zookeeper could be used.

Hope that helps a little.

S.