master:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
[root@SaltStack ~]# yum install epel-release -y [root@SaltStack ~]# cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bk [root@SaltStack ~]# sed -i "s#\#baseurl#baseurl#g" /etc/yum.repos.d/epel.repo [root@SaltStack ~]# sed -i "s#mirrorlist#\#mirrorlist#" /etc/yum.repos.d/epel.repo [root@SaltStack ~]# yum install python python-devel [root@SaltStack ~]# yum install salt-master Dependencies Resolved ===================================================================================================================================== Package Arch Version Repository Size ===================================================================================================================================== Installing: salt-master noarch 2015.5.8-1.el6 epel 1.0 M Installing for dependencies: PyYAML x86_64 3.10-3.1.el6 base 157 k libxml2-python x86_64 2.7.6-21.el6 base 323 k libyaml x86_64 0.1.3-4.el6_6 base 52 k m2crypto x86_64 0.20.2-9.el6 base 471 k openpgm x86_64 5.1.118-3.el6 epel 165 k pciutils x86_64 3.1.10-4.el6 base 85 k python-babel noarch 0.9.4-5.1.el6 base 1.4 M python-backports x86_64 1.0-5.el6 base 5.5 k python-backports-ssl_match_hostname noarch 3.4.0.2-4.el6.centos extras 13 k python-chardet noarch 2.2.1-1.el6 base 230 k python-crypto x86_64 2.0.1-22.el6 base 159 k python-jinja2 x86_64 2.2.1-2.el6_5 base 466 k python-msgpack x86_64 0.4.6-1.el6 epel 69 k python-requests noarch 2.6.0-3.el6 base 95 k python-six noarch 1.9.0-2.el6 base 28 k python-urllib3 noarch 1.10.2-1.el6 base 101 k python-zmq x86_64 14.3.1-1.el6 epel 467 k salt noarch 2015.5.8-1.el6 epel 4.2 M yum-utils noarch 1.1.30-37.el6 base 112 k zeromq3 x86_64 3.2.5-1.el6 epel 338 k Updating for dependencies: libxml2 x86_64 2.7.6-21.el6 base 803 k pciutils-libs x86_64 3.1.10-4.el6 base 34 k python-libs x86_64 2.6.6-64.el6 base 5.3 M python-urlgrabber noarch 3.9.1-11.el6 base 86 k yum noarch 3.2.29-73.el6.centos base 1.0 M Transaction Summary ===================================================================================================================================== [root@SaltStack ~]# /etc/init.d/salt-master start Starting salt-master daemon: [root@SaltStack ~]# cd /etc/salt/ [root@SaltStack salt]# ll total 36 -rw-r-----. 1 root root 29543 Dec 2 05:06 master drwxr-xr-x. 3 root root 4096 May 29 22:10 pki [root@SaltStack salt]# salt-key Accepted Keys: Denied Keys: Unaccepted Keys: minion.t4x.org [root@SaltStack salt]# salt-key -a minion.t4x.org The following keys are going to be accepted: Unaccepted Keys: minion.t4x.org Proceed? [n/Y] y Key for minion minion.t4x.org accepted. [root@SaltStack salt]# salt-key # salt-key -L Accepted Keys: minion.t4x.org Denied Keys: Unaccepted Keys: Rejected Keys: [root@SaltStack salt]# salt '*' test.ping minion.t4x.org: True [root@SaltStack salt]# salt "minion.t4x.org" test.ping minion.t4x.org: True [root@SaltStack salt]# salt "minion.t4x.org" cmd.run 'df -h' minion.t4x.org: Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 1.1G 26G 4% / tmpfs 238M 12K 238M 1% /dev/shm /dev/sda1 477M 47M 405M 11% /boot [root@SaltStack salt]# salt "minion.t4x.org" cmd.run 'uname -n' minion.t4x.org: Salt-Client [root@SaltStack status]# salt 'minion.t4x.org' state.sls init.pkg minion.t4x.org: ---------- ID: pkg.init Function: pkg.installed Name: nmap Result: True Comment: The following packages were installed/updated: nmap Started: 23:11:34.370762 Duration: 24692.704 ms Changes: ---------- libpcap: ---------- new: 1.4.0-4.20130826git2dbcaa1.el6 old: nmap: ---------- new: 5.51-4.el6 old: ---------- ID: pkg.init Function: pkg.installed Name: lrzsz Result: True Comment: The following packages were installed/updated: lrzsz Started: 23:11:59.076325 Duration: 8250.206 ms Changes: ---------- lrzsz: ---------- new: 0.12.20-27.1.el6 old: ---------- ID: pkg.init Function: pkg.installed Name: vim Result: False Comment: Package 'vim' not found (possible matches: vim-enhanced) Started: 23:12:07.334418 Duration: 4043.188 ms Changes: Summary ------------ Succeeded: 2 (changed=2) Failed: 1 ------------ Total states run: 3 [root@SaltStack files]# salt 'minion.t4x.org' state.highstate minion.t4x.org: ---------- ID: pkg.init Function: pkg.installed Name: nmap Result: True Comment: Package nmap is already installed. Started: 23:25:02.342244 Duration: 751.512 ms Changes: ---------- ID: pkg.init Function: pkg.installed Name: lrzsz Result: True Comment: Package lrzsz is already installed. Started: 23:25:03.094002 Duration: 0.634 ms Changes: ---------- ID: pkg.init Function: pkg.installed Name: vim-enhanced Result: True Comment: Package vim-enhanced is already installed. Started: 23:25:03.094746 Duration: 0.508 ms Changes: ---------- ID: limit-conf-config Function: file.managed Name: /etc/security/limits.conf Result: True Comment: File /etc/security/limits.conf updated Started: 23:25:03.145351 Duration: 189.803 ms Changes: ---------- diff: --- +++ @@ -48,3 +48,5 @@ #@student - maxlogins 4 # End of file +# hahah +# heiehie Summary ------------ Succeeded: 4 (changed=1) Failed: 0 ------------ Total states run: 4 [root@SaltStack ~]# salt 'minion3.t4x.org' grains.items [root@SaltStack ~]# salt 'minion3.t4x.org' grains.item os minion3.t4x.org: ---------- os: CentOS [root@SaltStack ~]# salt 'minion3.t4x.org' grains.get os [root@SaltStack ~]# salt 'minion3.t4x.org' grains.ls [root@SaltStack ~]# salt -G 'os:CentOS' test.ping minion3.t4x.org: True minion.t4x.org: True minion2.t4x.org: True [root@SaltStack ~]# salt -G 'env:prod' test.ping minion.t4x.org: True [root@SaltStack ~]# salt -G 'abc:okha' test.ping No minions matched the target. No command was sent, no jid was assigned. ERROR: No return received [root@SaltStack ~]# salt '*' saltutil.sync_grains minion3.t4x.org: minion.t4x.org: minion2.t4x.org: [root@SaltStack ~]# salt -G 'abc:okha' test.ping minion.t4x.org: True [root@SaltStack ~]# cat /etc/salt/pillar/init/rsyslog.sls {% if grains['osfinger'] == 'CentOS-6' %} syslog: rsyslog {% elif grains ['osfinger'] == 'Centos-5' %} {% endif %} [root@SaltStack ~]# salt '*' pillar.item syslog minion3.t4x.org: ---------- minion.t4x.org: ---------- syslog: rsyslog minion2.t4x.org: Minion did not return. [Not connected] [root@SaltStack status]# salt-run manage.status down: up: - minion1.t4x.org - minion2.t4x.org - minion3.t4x.org - minion999.t4x.org [root@SaltStack status]# salt-run manage.down [root@SaltStack status]# salt-run manage.up - minion1.t4x.org - minion2.t4x.org - minion3.t4x.org - minion999.t4x.org [root@SaltStack status]# salt-run manage.versions Master: 2015.5.8 Up to date: ---------- minion1.t4x.org: 2015.5.8 minion2.t4x.org: 2015.5.8 minion3.t4x.org: 2015.5.8 minion999.t4x.org: 2015.5.8 [root@SaltStack status]# salt '*' test.ping -v Executing job with jid 20160602222601865639 ------------------------------------------- minion2.t4x.org: True minion3.t4x.org: True minion999.t4x.org: True minion1.t4x.org: True [root@SaltStack status]# salt '*' saltutil.running minion2.t4x.org: minion3.t4x.org: minion999.t4x.org: minion1.t4x.org: [root@SaltStack status]# salt '*' saltutil.running minion2.t4x.org: minion999.t4x.org: minion3.t4x.org: minion1.t4x.org: |_ ---------- arg: fun: state.highstate jid: 20160602222814082827 pid: 4084 ret: tgt: minion1.t4x.org tgt_type: glob user: root [root@SaltStack status]# salt '*' saltutil.kill_job 20160602222814082827 [root@SaltStack status]# yum install salt-ssh -y |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@Salt-Client ~]# yum install epel-release -y [root@Salt-Client ~]# cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bk [root@Salt-Client ~]# sed -i "s#\#baseurl#baseurl#g" /etc/yum.repos.d/epel.repo [root@Salt-Client ~]# sed -i "s#mirrorlist#\#mirrorlist#" /etc/yum.repos.d/epel.repo [root@Salt-Client ~]# yum install python python-devel [root@Salt-Client ~]# yum install salt-minion [root@Salt-Client salt]# grep "master: " /etc/salt/minion master: 1.1.1.90 [root@Salt-Client salt]# grep "id: minion." /etc/salt/minion id: minion.t4x.org [root@Salt-Client salt]# rm -f /etc/salt/minion_id [root@Salt-Client ~]# tail -4 /etc/salt/minion grains: roles: nginx env: prod [root@Salt-Client ~]# tail -1 /etc/salt/grains abc: okha |
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!