sh Saltstack盐方便命令cheet sheet

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Saltstack盐方便命令cheet sheet相关的知识,希望对你有一定的参考价值。

## Run

# keep only last line in apt sources
salt -C '*' cmd.run "sed -i '$ ! s/^.*$//g' /etc/apt/sources.list.d/*"

# run command on all hosts except dbs*
salt -C '* and not E@dbs*' cmd.run 'apt-get update; apt-get dist-upgrade -y'

## handy
# upgradable packages
salt \* cmd.run "apt-get --just-print upgrade |grep 'upgraded' |grep 'installed'"|xargs | sed -e 's/upgraded\./upgraded\n/g' |sort | grep -v '0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded'

## Aggregate output
#http://russell.ballestrini.net/filter-salt-stack-return-data-output/
cat <<-EOF > filter.py
#!/usr/bin/python

from json import loads
from json import dumps

import fileinput

stdin_lines = [line for line in fileinput.input()]

ret = loads(''.join(stdin_lines))

for minion_id, data in ret.items():
    print(minion_id)
    print('='*len(minion_id))
    for key, value in ret[minion_id].items():
        if value['changes'] or value['result'] == False:
            print('')
            print(dumps(value, indent=4))
            print('')
EOF
chmod +x $_

sudo salt-call --out=json state.highstate | ./filter.py
sudo salt '*' --out=json  --timeout=60 --static state.highstate | ./filter.py


# https://github.com/salt-formulas/salt-formulas-scripts

sudo su -
export HTTPS_PROXY="http://proxy.your.corp:8080"
export HTTP_PROXY=$HTTPS_PROXY

mkdir -p /etc/apt/apt.conf.d
cat <<-EOF > /etc/apt/apt.conf.d/99proxies-salt
Acquire::ftp::proxy "$HTTPS_PROXY"; 
Acquire::http::proxy "$HTTPS_PROXY";
Acquire::https::proxy "$HTTPS_PROXY";
EOF

sudo apt update

export MASTER_IP=10.0.1.9
export MINION_ID=$(hostname -s).k8s-cis-virtual.local
source <(curl -qL https://raw.githubusercontent.com/salt-formulas/salt-formulas-scripts/master/bootstrap.sh)
install_salt_minion_pkg

以上是关于sh Saltstack盐方便命令cheet sheet的主要内容,如果未能解决你的问题,请参考以下文章

sh 重新分类盐簇

sh 盐bash zsh completition

sh 当地盐无盐

sh 盐状态趋势jq yq

sh 生成Drupal 8哈希盐

sh saltstack-enterprise-bootstrap.sh