初次使用 saltstack,若有语法什么的问题还请各位指点下。 sls 文件内容( https://github.com/fanne/salt)
目录结构:
[root@salt_master ~]# tree -Cv /srv/
/srv/
├── README.md
├── pillar
│ └── base
│ ├── jboss7.sls
│ └── top.sls
└── salt
└── base
├── bashrc_init
│ └── bashrc_init.sls
├── cp_file.sls
├── del_file.sls
├── jboss7
│ ├── file
│ │ ├── jboss-as-7.1.0.Final.zip
│ │ ├── jboss-as-standalone
│ │ ├── jboss-as.conf
│ │ └── standalone.conf
│ └── jboss7.sls
├── jdk_7_79
│ ├── file
│ │ ├── env_jdk.txt
│ │ └── jdk-7u79-linux-x64.rpm
│ └── jdk_7_79.sls
├── jdk_8_121
│ ├── file
│ │ ├── env_jdk.txt
│ │ └── jdk-8u121-linux-x64.rpm
│ └── jdk_8_121.sls
└── top.sls
11 directories, 18 files
现在对 salt_node_02 节点安装 jdk 和 jboss 内容。 安装 jdk 前,salt_node_02 上的 jdk 信息
[root@salt_node_02 ~]# java -version
-bash: java: command not found
在 master 端执行:
[root@salt_master ~]# salt 'salt_node_02' state.sls jdk_7_79.jdk_7_79 -l debug
输出结果:
[DEBUG ] LazyLoaded nested.output
[DEBUG ] LazyLoaded nested.output
[DEBUG ] LazyLoaded nested.output
[DEBUG ] LazyLoaded nested.output
salt_node_02:
----------
ID: jdk-install
Function: file.managed
Name: /usr/local/src/jdk-7u79-linux-x64.rpm
Result: True
Comment: File /usr/local/src/jdk-7u79-linux-x64.rpm updated
Started: 16:59:37.933787
Duration: 13352.812 ms
Changes:
----------
diff:
New file
mode:
0644
----------
ID: jdk-install
Function: cmd.run
Name: cd /usr/local/src && rpm -ivh jdk-7u79-linux-x64.rpm
Result: True
Comment: Command "cd /usr/local/src && rpm -ivh jdk-7u79-linux-x64.rpm" run
Started: 16:59:51.287182
Duration: 27559.508 ms
Changes:
----------
pid:
2009
retcode:
0
stderr:
stdout:
Preparing... ##################################################
jdk ##################################################
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
----------
ID: jdk-evn
Function: file.append
Name: /etc/profile
Result: True
Comment: Appended 7 lines
Started: 17:00:18.846921
Duration: 153.225 ms
Changes:
----------
diff:
---
+++
@@ -76,3 +76,10 @@
unset i
unset -f pathmunge
+export PATH=$PATH:/usr/local/bin
+#set java environment
+JAVA_HOME=/usr/java/jdk1.7.0_79
+CLASSPATH=.:$JAVA_HOME/lib/tools.jar
+PATH=$JAVA_HOME/bin:$PATH
+LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
+export JAVA_HOME CLASSPATH PATH LD_LIBRARY_PATH
----------
ID: jdk-evn
Function: cmd.run
Name: source /etc/profile
Result: True
Comment: Command "source /etc/profile" run
Started: 17:00:19.000263
Duration: 202.819 ms
Changes:
----------
pid:
2203
retcode:
0
stderr:
stdout:
Summary for salt_node_02
------------
Succeeded: 4 (changed=4)
Failed: 0
------------
Total states run: 4
Total run time: 41.268 s
[DEBUG ] jid 20170524165954616622 found all minions set(['salt_node_02'])
此时,salt_node_02 上的 jdk 信息
[root@salt_node_02 ~]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
然后安装 jboss7 内容,同样在 master 端执行命令: 然后 debug 日志一直打印以下信息
[root@salt_master ~]# salt 'salt_node_02' state.sls jboss7.jboss7 -l debug
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Missing configuration file: /root/.saltrc
[DEBUG ] Configuration file path: /etc/salt/master
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Missing configuration file: /root/.saltrc
[DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'salt_master_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] LazyLoaded local_cache.get_load
[DEBUG ] Reading minion list from /var/cache/salt/master/jobs/58/51c7350809d96364ef260721ee618e6765bf47830c9db82440105eeb919ced/.minions.p
[DEBUG ] get_iter_returns for jid 20170524170231748034 sent to set(['salt_node_02']) will timeout at 17:02:36.830281
[DEBUG ] Checking whether jid 20170524170231748034 is still running
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'salt_master_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG ] Passing on saltutil error. This may be an error in saltclient. 'retcode'
[DEBUG ] Checking whether jid 20170524170231748034 is still running
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'salt_master_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG ] Passing on saltutil error. This may be an error in saltclient. 'retcode'
[DEBUG ] Checking whether jid 20170524170231748034 is still running
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'salt_master_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG ] Passing on saltutil error. This may be an error in saltclient. 'retcode'
[DEBUG ] Checking whether jid 20170524170231748034 is still running
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'salt_master_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG ] Passing on saltutil error. This may be an error in saltclient. 'retcode'
[DEBUG ] Checking whether jid 20170524170231748034 is still running
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'salt_master_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG ] Passing on saltutil error. This may be an error in saltclient. 'retcode'
master 端一直在执行,没法结束。
在 node 端查看信息,发现 jboss 已经安装上了:
[root@salt_node_02 ~]# ps -ef|grep java
root 2358 2305 1 17:02 ? 00:00:06 /usr/java/jdk1.7.0_79/bin/java -D[Standalone] -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xms32m -Xmx256m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml -Dorg.jboss.boot.log.file=/usr/local/src/jboss-as-7.1.0.Final/standalone/log/boot.log -Dlogging.configuration=file:/usr/local/src/jboss-as-7.1.0.Final/standalone/configuration/logging.properties -jar /usr/local/src/jboss-as-7.1.0.Final/jboss-modules.jar -mp /usr/local/src/jboss-as-7.1.0.Final/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=/usr/local/src/jboss-as-7.1.0.Final -c standalone.xml
root 2648 1968 0 17:12 pts/2 00:00:00 grep java
[root@salt_node_02 ~]# netstat -ntpl|grep java
tcp 0 0 127.0.0.1:9999 0.0.0.0:* LISTEN 2358/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2358/java
tcp 0 0 0.0.0.0:4447 0.0.0.0:* LISTEN 2358/java
tcp 0 0 127.0.0.1:9991 0.0.0.0:* LISTEN 2358/java
[root@salt_node_02 ~]#
然后 master 端就是没法退出来,问题是出现哪里的?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.