Why Ruby scripting for DevOps?
I did little search on the google trends what all tools used in configuration management found the following:
- Chef
- Puppet
- Ansible
- SaltTalk
There are different tools at varety of reasons, all of them are looking for the scripting language that could be a definative way of expressing. They all need client-server model but fastest communicatiive way. Better way of memory management by itself. writing could be as easy as possible.
Configuration Tool analysis on recent demand |
Anyway my learning of Ruby script is justified by the above trends in demand currently. Lets do this and progress towards success in DevOps tools easily.
My list of understanding topics are :
- Math Arithmetic operators
- comparison operators
- String usage
Now how to use your Ruby variable got some idea. Then you goto develop the Ruby script I will not use such syntaxError.
Math operators in Ruby
Here I am experimenting with some of the operators that does simple calucations. I've opened an irb shell to execute these operations.irb(main):001:0> 5.4 - 3 => 2.4000000000000004 irb(main):002:0> 3 * 4 => 12 irb(main):003:0> 7 / 3 => 2 irb(main):004:0> 7.0 / 3 => 2.3333333333333335 irb(main):005:0> 7.0 3 SyntaxError: (irb):5: syntax error, unexpected tINTEGER, expecting end-of-input from /bin/irb:12:in `' irb(main):006:0> 7.0/3 => 2.3333333333333335 irb(main):007:0> 2**3 => 8 irb(main):008:0> 4**9 => 262144 irb(main):009:0> 1.4***3 SyntaxError: (irb):9: syntax error, unexpected * 1.4***3 ^ from /bin/irb:12:in ` ' irb(main):010:0> 1.4***3 SyntaxError: (irb):10: syntax error, unexpected * 1.4***3 ^ from /bin/irb:12:in ` ' irb(main):011:0> 1.4**3 => 2.7439999999999993 irb(main):012:0> 4<6> true irb(main):013:0> 21 => 21 irb(main):014:0> 2ge5 SyntaxError: (irb):14: syntax error, unexpected tIDENTIFIER, expecting end-of-input from /bin/irb:12:in ` ' irb(main):015:0> 4<=2 => false irb(main):016:0> 1+2==4 => false irb(main):017:0> 1+2==3 => true 6>
Strings in Ruby
I am here to expose when we do mistakes in Ruby scripting, why we are here to get this. To cope up with multipe devops problems and get the solutions with Ruby but to began or conclude something we need strings.irb(main):027:0> name x NoMethodError: undefined method `name' for main:Object from (irb):27 from /bin/irb:12:in `' irb(main):028:0> x => 3 irb(main):029:0> name | x NoMethodError: undefined method `|' for "hari":String from (irb):29 from /bin/irb:12:in ` ' irb(main):030:0> name and x => 3 irb(main):031:0> x=3 => 3 irb(main):032:0> y=4 => 4 irb(main):033:0> x+y => 7 irb(main):034:0> y+=1 => 5 irb(main):035:0> x-=2 => 1 irb(main):036:0> name +="jitta" => "harijitta"
My interactive ruby commands failed sometimes it is not good but I learnt what can be string type objects better way to use them in the scripting.