使用普通用户安装jdk1.7,salt-minion端是ubuntu14.04系统64bit
普通用户如下:
root@iZ23f6c5z8tZ:/srv/salt/base# cat init/user.sls user: user.present: - name: www - shell: /bin/bash # - password: $1$ABpNeJ/S$YiTlhxqqjaSA/aQN5mYAE.
注:设置密码使用openssl passwd -1 123321即可
jdk的sls文件如下:
root@iZ23f6c5z8tZ:/srv/salt/base# cat jdk/install.sls include: - init.user jdk-install: file.managed: - name: /data/src/jdk-7u79-linux-x64.gz - source: salt://jdk/files/jdk-7u79-linux-x64.gz - user: www - group: www - mode: 644 cmd.run: - name: cd /data/src/ && tar fxz jdk-7u79-linux-x64.gz && mv jdk1.7.0_79 /usr/local/jdk - unless: test -d /usr/local/jdk - require: - file: jdk-install jdk-config: file.append: - name: /etc/profile - text: - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH - export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
安装jdk,jdk相关的包传输比较慢,使用cp.get_dir salt://src_dir_packages /dest
salt ‘*‘ state.sls jdk.install
安装完成后可以到客户端查看下
www@node1:~$ 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)
本文出自 “村里的男孩” 博客,请务必保留此出处http://noodle.blog.51cto.com/2925423/1744611
原文地址:http://noodle.blog.51cto.com/2925423/1744611