Saltstack Set Roles with Pillar

Saltstack Set Roles with Pillar

Sometimes, we would like to set roles for our servers. This is can be done to define  /srv/pillar/top.sls.

for example

we have:

web_prod01

web_prod02

web_prod02

PART 1 working with pillar

  1. then we can define like this:
base:
   'web_prod*'
       - prod_role

 

2. and in the /srv/pillar/prod_role.sls

role: webserver

3. refresh the pillar file to all matched web_prod*minions

salt “web_prod*” saltutil.refresh_pillar

4. then test it

salt -I ‘role:webserver’ test.ping

additional we can set matched in state file:

base:
 'role:webserver':
   - match: pillar
   - state
   - state2

Reference links:

PART 2 another workaround with external nodegroups

include files in /etc/salt/master

# Include config from several files and directories:

include:

   – /opt/test/saltmgt/nodegroups.yaml

2. cat /opt/test/saltmgt/nodegroups.yaml

nodegroups:

   test1:

     – ‘*prod*’

 

more useful:

Docker web proxy

 

 

Ubuntu 14.04 LTS

For Ubuntu 14.04 LTS who uses SysVinit, you should modify /etc/default/docker file:

# cat /etc/default/docker
# Docker Upstart and SysVinit configuration file

#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
#   Please see the documentation for "systemd drop-ins":
#   https://docs.docker.com/engine/articles/systemd/
#

.......
# If you need Docker to use an HTTP proxy, it can also be specified here.
export http_proxy="http://web-proxy.corp.xxxxxx.com:8080/"
export https_proxy="https://web-proxy.corp.xxxxxx.com:8080/"
......

Then restart docker:

service docker restart

Ubuntu 16.04 LTS

For Ubuntu 16.04 LTS who uses Systemd, you can follow this post:

(1) Create a systemd drop-in directory:

mkdir /etc/systemd/system/docker.service.d

(2) Add proxy in /etc/systemd/system/docker.service.d/http-proxy.conf file:

# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=https://web-proxy.corp.xxxxxx.com:8080/"
Environment="HTTPS_PROXY=https://web-proxy.corp.xxxxxx.com:8080/"
Environment="NO_PROXY=localhost,127.0.0.1,localaddress,.localdomain.com"

(3) Flush changes:

systemctl daemon-reload

(4) Restart Docker:

systemctl restart docker

Docker Fundamental (1)

笔记:

记录Docker的一些基本命令

  1. Docker pull – pull docker image from public docker hub
  2. Docker image – show local image
  3. Docker run – run once using specific dock
  4. Docker ps
  5. Docker search <containerName>