Thursday, December 31, 2015

Salt common modules

sys.docReturn the docstrings for all execution modules and functions
  • salt * sys.doc test.ping
  • salt-call sys.doc test
  • salt-call sys.doc  # To see documentation for all modules
sys.state_doc: Get help for state modules and functions. Return the docstrings for all states.
  • salt-call sys.state_doc user.present
sys.list_modules: List the execution modules loaded on the minion
  • salt-call sys.list_modules
sys.list_functionsList the execution functions for all modules. 
  • salt-call sys.list_functions sys 

SaltStack: [ERROR] The master key has changed and [CRITICAL] The Salt Master has rejected this minion's public key!

When the IP address of Salt master got changed and then a salt-minion started throwing the below error

[ERROR   ] The master key has changed, the salt master could have been subverted, verify salt master's public key
[CRITICAL] The Salt Master server's public key did not authenticate!
The master may need to be updated if it is a version of Salt lower than 2015.8.3, or
If you are confident that you are connecting to a valid Salt Master, then remove the master public key and restart the Salt Minion.
The master public key can be found at:
/etc/salt/pki/minion/minion_master.pub
Invalid master key




To get rid of this error, I ran below commands on troubled minion
  • cd /etc/salt/pki/minion/
  • mv minion_master.pub minion_master.pub.old
  • mv minion.pem minion.pem.old
  • mv minion.pub minion.pub.old
  • salt-key --include-all --reject='ubuntu-14.04-amd64-vbox'         #on master
  • service salt-minion restart
  • salt-key --include-all --accept=ubuntu-14.04-amd64-vbox --yes      # on master
  • service salt-master restart                    # on master
But this didn't help. The minion started throwing another error

root@ubuntu-14:/etc/salt/pki/minion# salt-call test.ping
[CRITICAL] The Salt Master has rejected this minion's public key!
To repair this issue, delete the public key for this minion on the Salt Master and restart this minion.
Or restart the Salt Master in open mode to clean out the keys. The Salt Minion will now exit.


To get rid of this error, I had to run
  • salt-key --delete-all   # on master
  • service salt-minion restart  # on all minions including master
  • salt-key --accept-all


Tuesday, December 29, 2015

Remote debug a Atlassian Stash plugin from Eclipse

While developing a Atlassian Stash plugin, you may need to debug the code using break points in Eclipse. But since the Stash plugin is deployed on a remote web container (though it is in localhost), you can't debug it straight way. You need to establish a remote debug session

Step 1: Run your stash application in debug mode

  • atlas-debug

Step 2: Configure Remote Debug configurations in Eclipse

  • Run -> Debug Configurations -> Remote Java Application -> New 
  • Host = localhost
  • Port = 5005   # This is the debug port. Normal port is 7999

Step 3: Add a break point on your code in eclipse

Step 4: Run 'Debug'

  • Run ->  Debug

Step 5: Invoke your plugin

  • To get an entry to your code in eclipse, you need to touch the part of the application to which your code is related.
  • For example in my case, I went to Pull Requests (coz my plugin was dealing with pull requests) and clicked on one of the pending pull request.

Step 6: Start debug

  • Step Over (F6)  or Step In (F5)

SaltStack Quick start

Reference: This blog post is prepared by referring the book "Salt Essentials; Craig Sebenik & Thomas Hatch; Oreilly publications"

Installation

  • yum list salt salt-master salt-minion
  • yum install -y salt salt-minion   #Install these 2 packages on minions & master
  • yum install -y salt-master   # Install this package on master

Configuring master IP/DNS in minions

The basic minion configuration is located in /etc/salt/minion.You need to configure each minion with the DNS name or IP address of your Salt master. 

The default Salt master configured is

$ grep '#master:' /etc/salt/minion
#master: salt

This needs to be changed to our master IP or DNS name

Monday, December 28, 2015

Virtualization with Vagrant and VirtualBox - Quick Start


Getting Ready

  • Install Vagrant & VirtualBox
  • Visit http://www.vagrantbox.es/ and select a Vagrant Box you are interested. (Click on Copy to copy the URL)
  • mkdir -p vagrant/centos65
  • cd vagrant/centos65

Action!!!

$ vagrant init centos65 https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.