Quantcast
Channel: admin – Robert Chen
Viewing all articles
Browse latest Browse all 18

Using SaltStack for automation

$
0
0

Introduction

  • Salt platform or SaltStack is a Python-based open source configuration management and remote execution application. Supporting the “infrastructure-as-code” approach to deployment and cloud management, it competes primarily with Puppet, Chef, and Ansible.

Install salt

On 10.68.80.129:

root@opscoder-virtual-machine:~# add-apt-repository ppa:saltstack/salt

You are about to add the following PPA to your system:

Salt, the remote execution and configuration management tool.

OK

root@opscoder-virtual-machine:~# apt-get install python-software-properties

 

root@opscoder-virtual-machine:~# echo deb http://ppa.launchpad.net/saltstack/salt/ubuntu `lsb_release -sc` main | sudo tee /etc/apt/sources.list.d/saltstack.list

deb http://ppa.launchpad.net/saltstack/salt/ubuntu precise main

root@opscoder-virtual-machine:~# wget -q -O- “http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4759FA960E27C0A6” | sudo apt-key add –

OK

 

25 apt-get install salt-master

26 apt-get install salt-minion

27 apt-get install salt-syndic

 

/etc/salt/minion

master: 10.68.80.129

id: 10.68.80.129

 

root@opscoder-virtual-machine:/etc/salt# service salt-minion restart

 

root@opscoder-virtual-machine:~# salt-key

Accepted Keys:

Unaccepted Keys:

10.68.80.129

Rejected Keys:

 

root@opscoder-virtual-machine:~# salt-key -a 10.68.80.129

The following keys are going to be accepted:

Unaccepted Keys:

10.68.80.129

Proceed? [n/Y] y

Key for minion 10.68.80.129 accepted.

 

Automation management tasks

root@opscoder-virtual-machine:~# salt ‘*’ cmd.run_all “hostname”

10.68.80.129:

———-

pid:

8267

retcode:

0

stderr:

 

stdout:

opscoder-virtual-machine

 

 

root@opscoder-virtual-machine:~# salt ‘*’ disk.percent /

10.68.80.129:

30%

 

install salt client on centos 6.5

[root@centos65 ~]# rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

Retrieving http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

warning: /var/tmp/rpm-tmp.a8iOLh: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY

Preparing… ########################################### [100%]

1:epel-release ########################################### [100%]

 

 

       yum install salt-minion -y

 

[root@centos65 salt]# pwd

/etc/salt

[root@centos65 salt]# grep master minion

# Set the location of the salt master server, if the master server cannot be

#master: salt

master: 10.68.80.129

 

 

id: 10.68.80.130

 

service salt-minion start

 

root@opscoder-virtual-machine:~# salt-key

Accepted Keys:

10.68.80.129

Unaccepted Keys:

10.68.80.130

Rejected Keys:

root@opscoder-virtual-machine:~# salt-key -a 10.68.80.130

The following keys are going to be accepted:

Unaccepted Keys:

10.68.80.130

Proceed? [n/Y] y

Key for minion 10.68.80.130 accepted.

 

root@opscoder-virtual-machine:/etc/salt# salt ‘*’ test.ping

10.68.80.126:

True

10.68.80.129:

True

10.68.80.130:

True

 

 

root@opscoder-virtual-machine:/etc/salt# salt ‘*’ cmd.run “hostname”

10.68.80.126:

win2012

10.68.80.129:

opscoder-virtual-machine

10.68.80.130:

centos65

 

root@opscoder-virtual-machine:/etc/salt# salt ‘*’ disk.percent /

10.68.80.126:

‘disk.percent’ is not available.

10.68.80.129:

30%

10.68.80.130:

12%

 

install package:

root@opscoder-virtual-machine:/etc/salt# salt ‘*’ pkg.install nmap

10.68.80.126:

———-

10.68.80.129:

———-

nmap:

———-

new:

5.21-1.1ubuntu1

old:

 

10.68.80.130:

———-

 

root@opscoder-virtual-machine:/etc/salt# salt ‘*’ network.interfaces

10.68.80.129:

———-

eth0:

———-

hwaddr:

00:50:56:81:23:f9

inet:

———-

– address:

10.68.80.129

– broadcast:

10.68.80.255

– label:

eth0

– netmask:

255.255.255.0

inet6:

———-

– address:

fe80::250:56ff:fe81:23f9

– prefixlen:

64

up:

True

lo:

———-

hwaddr:

00:00:00:00:00:00

inet:

———-

– address:

127.0.0.1

– broadcast:

None

– label:

lo

– netmask:

255.0.0.0

inet6:

———-

– address:

::1

– prefixlen:

128

up:

True

10.68.80.130:

———-

eth0:

———-

hwaddr:

00:50:56:81:67:8d

inet:

———-

– address:

10.68.80.130

– broadcast:

10.68.80.255

– label:

eth0

– netmask:

255.255.255.0

inet6:

———-

– address:

fe80::250:56ff:fe81:678d

– prefixlen:

64

up:

True

lo:

———-

hwaddr:

00:00:00:00:00:00

inet:

———-

– address:

127.0.0.1

– broadcast:

None

– label:

lo

– netmask:

255.0.0.0

inet6:

———-

– address:

::1

– prefixlen:

128

up:

True

10.68.80.126:

———-

Intel(R) 82574L Gigabit Network Connection:

———-

hwaddr:

00:50:56:81:21:D6

inet:

———-

– address:

10.68.80.126

– broadcast:

10.68.80.254

– label:

Intel(R) 82574L Gigabit Network Connection

– netmask:

255.255.255.0

inet6:

———-

– address:

fe80::5ff:e430:3cf3:c5a

up:

True

 

The post Using SaltStack for automation appeared first on Robert Chen.


Viewing all articles
Browse latest Browse all 18

Trending Articles