saltstack控制windows实现静默安装weblogic

saltstack控制windows实现静默安装weblogic,实现批量部署,在此记录下来,希望可以帮你少入坑

1.用到的软件包

wls1036_win32.exe Windows的weblogic安装包
jdk-6u37-windows-x64.exe Windows的jdk安装包
Salt-Minion-2018.3.3-Py2-AMD64-Setup.exe Windows的salt客户端安装包,注意:这个区分cpu

2.首先安装windows客户端

Windows客户端安装比较简单,根据提示点下一步就可以,注意:中间要输saltmaster的ip和自己的ip

注意关闭两端防火墙’

安装完成后在saltmaster端输入salt-key -A同意加入即可

saltstack控制windows实现静默安装weblogic_第1张图片

3.可以使用一下命令测试连通性

4.整个部署文件结构如下(现在就创建Pkg,File目录)

saltstack控制windows实现静默安装weblogic_第2张图片

整体分为3大步:

安装jdk

安装weblogic

创建域

实现思路:  分发软件包,执行powershell脚本来进行windows的安装

5.首先需要进行jdk的安装,编写jdkinstall.sls内容如下:

[root@localhost salt]# cat jdkinstall.sls 
jdk-upload:
  cmd.run:
    - name: md D:\app
  file.managed:
    - name: D:\app\jdk-6u37-windows-x64.exe
    - source: salt://pkg/jdk-6u37-windows-x64.exe
jdk-install:
  cmd.script:
    - source: salt://file/jdk.ps1
- shell: powershell

6.Jdk.ps1文件内容如下(现在的操作都是在/srv/salt中进行)

[root@localhost salt]# cat file/jdk.ps1 
d:\app\jdk-6u37-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR=C:\Java\x64\jdk1.6.0_37 /INSTALLDIRPUBJRE=C:\Java\x64\jre1.6.0_37

上面sls的作用:在win创建D:\app目录,远程将jdk软件包放进windows机器,执行jdk.ps1来安装jdk,把相应软件包放进相应目录即可,简介:部署jdk环境

7.编写wlsinstall.sls

[root@localhost salt]# cat wlsinstall.sls 
include:
   - jdkinstall

silent-upload:
  file.managed:
    - name: D:\silent.xml
    - source: salt://file/silent.xml
wls-upload:
  file.managed:
    - name: D:\wls1036_win32.exe
    - source: salt://pkg/wls1036_win32.exe
wls-install:
  cmd.script:
    - source: salt://file/wlsinstall.ps1
    - shell: powershell    
    - require:
      - file: silent-upload
      - file: wls-upload

以上sls的作用:远程分发silent文件(用来静默安装),远程分发weblogic软件包,执行ps1脚本来进行安装

下面是silent.xml的内容:

[root@localhost salt]# cat file/silent.xml 









     
       
       
       
       
       
       
       
       

   

以下为wlsinstall.ps1的内容:(内容为静默安装weblogic)

[root@localhost salt]# cat file/wlsinstall.ps1 
D:\wls1036_win32.exe -mode=silent -silent_xml=D:\silent.xml

8.下面编写wlsstart.sls,作用:分发静默创建域的rsp文件,执行ps1文件来创建域,开启weblogic管理台

[root@localhost salt]# cat wlsstart.sls 
rsp-upload:
  file.managed:
    - name: D:\createdomain.rsp
    - source: salt://file/createdomain.rsp
rsp-install:
  cmd.script:
    - source: salt://file/rspinstall.ps1
    - shell: powershell
    - require:
      - file: rsp-upload
wls-start:
  cmd.script:
    - source: salt://file/wlsstart.ps1
    - shell: powershell
    - require:
      - cmd: rsp-install

Createdomain.rsp内容如下,作用:配置创建静默创域的一些信息 

read template from "D:\app\weblogic\common\templates\domains\wls.jar";
 
set JavaHome "C:\Java\x64\jdk1.6.0_37"; 
set ServerStartMode "dev"; 

find Server "AdminServer" as AdminServer;
set AdminServer.ListenAddress "";
set AdminServer.ListenPort "8001";
set AdminServer.SSL.Enabled "true";
set AdminServer.SSL.ListenPort "8002";
 
//We can directly create a new managed server.
create Server "base" as BASE;
set BASE.ListenAddress "";
set BASE.ListenPort "8003";
//set BASE.SSL.Enabled "true";
//set BASE.SSL.ListenPort "8004″;
 
//Create Machine
create Machine "base" as Machinename;
 
//use templates default weblogic user
find User "weblogic" as u1;
set u1.password "weblogic123";
 
//create a new user
create User "weblogic2" as u2;
set u2.password "weblogic123";
 
write domain to "D:\app\source_program\domains\base_domain/"; 
 
// The domain name will be "demo-domain"
 
close template;

rspinstall.ps1内容如下,作用:静默创建weblogic域

[root@localhost salt]# cat file/rspinstall.ps1 
D:\app\weblogic\common\bin\config.exe -mode=silent -silent_script=D:\createdomain.rsp

Wlsstart.ps1内容如下,作用:执行开启weblogic的命令

[root@localhost salt]# cat file/wlsstart.ps1 
D:\app\source_program\domains\base_domain\bin\startWebLogic.cmd

三个sls文件可以放在一起来执行

最终的wlsinstall.sls内容如下,这里把安装和创域的过程都放在了一个文件,用include把jdk的安装sls放了进来

[root@localhost salt]# cat wlsinstall.sls 
include:
   - jdkinstall

silent-upload:
  file.managed:
    - name: D:\silent.xml
    - source: salt://file/silent.xml
wls-upload:
  file.managed:
    - name: D:\wls1036_win32.exe
    - source: salt://pkg/wls1036_win32.exe
wls-install:
  cmd.script:
    - source: salt://file/wlsinstall.ps1
    - shell: powershell    
    - require:
      - file: silent-upload
      - file: wls-upload
rsp-upload:
  file.managed:
    - name: D:\createdomain.rsp
    - source: salt://file/createdomain.rsp
rsp-install:
  cmd.script:
    - source: salt://file/rspinstall.ps1
    - shell: powershell
    - require:
      - file: rsp-upload
wls-start:
  cmd.script:
    - source: salt://file/wlsstart.ps1
    - shell: powershell
    - require:
      - cmd: rsp-install

salt 172.16.22.89 state.sls wlsinstall --timeout=300 执行就可以部署成功

网上相关文档很少,如果你正好需要用到,可以参考,这里没有具体详细参数的说明因为内容太多

下面是官网步骤,也是挺坑的

https://docs.oracle.com/cd/E23943_01/doc.1111/e14142/silent.htm#WLSIG190

你可能感兴趣的:(saltstack控制windows实现静默安装weblogic)