Posts

Showing posts from 2016

SALT-SSH: AttributeError: 'module' object has no attribute 'fromstringlist'

This error triggers when the salt-master is CentOS6 and the target is CentOS7.  The salt-master on CentOS6 would copy ElementTree.py to the minion on CentOS7 but  python2.6's lib cannot run directly on python2.7. To overcome this issue, On the salt-master: 1). Find the thin.py # find / -name thin.py /usr/lib/python2.6/site-packages/salt/runners/thin.py /usr/lib/python2.6/site-packages/salt/utils/thin.py In /usr/lib/python2.6/site-packages/salt/utils/thin.py try: import xml HAS_XML = True except ImportError: HAS_XML = False Modify as: try: import xml HAS_XML = False except ImportError: HAS_XML = False 2). remove the thin.tgz from cache # rm /var/cache/salt/master/thin/thin.tgz 3). Perform the salt-ssh command again with -W ( -W for Select a random temp dir to deploy on the remote system. The dir will be cleaned after the execution.) # salt-ssh -W rnd test.ping # salt-ssh -W rnd disk.usage

State system (High State & Low State) in SALT STACK:

Image
For this example we are using top.sls and httpd_require.sls wihch contain, # cat top.sls base:  '*':   - httpd_require root@ranjith1:/srv/salt# cat httpd_require.sls install_httpd:  pkg.installed:    - name: httpd  service.running:   - name: httpd   - enable: True   - require:     - file: install_httpd  file.managed:   - name: /var/www/html/index.html   - source: salt://index1.html   - user: root   - group: root   - mode: 644   - require:     - pkg: install_httpd High state: We can see all the aspects of high state system while working with state files( .sls), There are three specific components. - High data: - SLS file: - High State   - Each individual State represents a piece of high data.    - for example:        file.managed:     - name: /var/www/html/index.html     - source: salt://index1.html     - user: root     - group: root     - mode: 644     - require:       - pkg: install_httpd   - Salt will compile all relevant SLS inside the top.sls, When these files are tied tog

Integrate SaltStack with other applications through SALT-API(rest_cherrypy):

 I was looking for the config management / remote execution tools and found SALT-STACK which fulfills the exact needs.   But, when it comes to integrate with other / our custom applications we had rest_tornado, rest_wsgi and rest_cherrypy options, i must thanks to Benjamin Cane and The Reluctant Tecchie who gave me the simple and best understanding about the SALT-API(rest_cherrypy) and configuring it to allow third party services to initiate SaltStack executions.  Well, I'm using Ubuntu server as my salt-master(single salt-master and one Minion: 'my-api-minion' connected.) so i took the apt-get method to install the package , # apt-get install salt-api Generating the key to create SSL Certificate. # openssl genrsa -out /etc/ssl/private/key.pem 4096 Sign the key and generate a certificate: # openssl req -new -x509 -key /etc/ssl/private/key.pem -out /etc/ssl/private/cert.pem -days 1826 rest_cherrypy configuration: added below values in /etc/salt/master: rest_cherrypy: