Ansible: i need to start a server from one node if the server in another node starts.

Visto 196 veces
Saltar al primer mensaje no leído

Rajesh Martha

no leída,
26 abr 2017, 9:09:4726/4/17
a Ansible Project
ANSIBLE VERSION

ansible 2.2.1.0
Hi All, I need Help for starting and Stopping the servers in WebSphere,
I have a 9 nodes in websphere, Node1 have 3 servers(Message, CW, CP), Node2 Have 3 servers((Message, CW, CP), Node3 have 2(CW, CP) servers, Node4 2 servers(CW, CP), Node5 have 3 servers(ASS, CW, WEB), Node6 have 3 servers(ASS, CW, WEB), Node7 have 3 serers(ASS, CW, WEB), Node 8 have 3 servers(ASS, CW, WEB), Node 9 have 1 servers(CW),

With My ansibel script, First I am staring Deployment Manager, then i sync the Nodes to deplyment manger if Dmanger running, if node sync successful then i am starting nodeagents,
if Nodeagents started successfully then i am starting server1(Message) on Node1 and 2,

Here i need to start the servers(ASS) on Node5, Node6, Node7 and Node8 if server(Message) started successfully on Node1 and Node2,

Here i need to start the Servers(WEB) on Node5, Node6, Node7 and Node8 if server(Message) started successfully on Node1 and Node2, and Server(ASS) started successfully on Node5, Node6, Node7 and Node8....

Can some one please help to write the code in Ansible, The script i have written are attached here,
i am also attaching my hostfile.


[ATST-CURAMDMGR]

xx.xxx.xx.1

[ATST-CURAMAPPSRV]

xx.xxx.xx.1

xx.xxx.xx.2

xx.xxx.xx.3

xx.xxx.xx.4

xx.xxx.xx.5

xx.xxx.xx.6

xx.xxx.xx.7

xx.xxx.xx.8

xx.xxx.xx.9


---
-
  become: true
  become_user: wsadmin
  any_errors_fatal: true
  hosts: ATST-CURAMDMGR
  tasks:
    -
      ping: ~
    -
      name: "Displaying Hostname for Curam DMGR Profile"
      register: hostnameforcuramdmgr
      shell: hostname
    -
      debug: var=hostnameforcuramdmgr.stdout_lines
    -
      shell: "{{ was_home }}/bin/serverStatus.sh -all -username {{ dmgr_username }} -password {{ dmgr_password }}"
      name: "checking the DMGR status for Curam"
      register: dmgr_status
    -
      debug: var=dmgr_status.stdout_lines
    -
      shell: "{{ dmgr_home }}/clearClassCache.sh"
      name: "Clearing the cache for Curam Dmgr Profile"
      when: '"The Deployment Manager \"dmgr\" cannot be reached" in dmgr_status.stdout'
      register: clearcache
    -
      debug: var=clearcache.stdout_lines
    -
      shell: "{{ dmgr_home }}/osgiCfgInit.sh"
      name: "Clearing the osgicache for Curam Dmgr Profile"
      when: '"The Deployment Manager \"dmgr\" cannot be reached" in dmgr_status.stdout'
      register: clearcacheosgi
    -
      debug: var=clearcacheosgi.stdout_lines
    -
      shell: "{{ was_home }}/bin/startManager.sh -profileName {{ dmgrprofile_name }}"
      name: "Starting the Curam DMGR profile if not running"
      when: '"The Deployment Manager \"dmgr\" cannot be reached" in dmgr_status.stdout'
      register: startdmgr
    -
      debug: var=startdmgr.stdout_lines
  vars:
    -
      dmgrprofile_name: Dmgr01
    -
      dmgr_username: wsadmin
    -
      dmgr_password: ******
    -
      was_home: /opt/WebSphere/AppServer*/
    -
      dmgr_home: "/opt/WebSphere/AppServer*/profiles/Dmgr01/bin"
-
  become: true
  any_errors_fatal: true
  become_user: wsadmin
  hosts: ATST-CURAMAPPSRV
  tasks:
    -
      ping: ~
    -
      name: "checking the Curam nodeagent status"
      shell: "{{ profile_home }}/serverStatus.sh nodeagent -username {{ dmgr_username2 }} -password {{ dmgr_password2 }}"
      register: nodeagentstatus
    -
      debug: var=nodeagentstatus.stdout_lines
    -
      name: "Clearing the Curam AppPrfiles cache"
      shell: "{{ profile_home }}/clearClassCache.sh"
      when: '"The Node Agent \"nodeagent\" cannot be reached" in nodeagentstatus.stdout'
      register: nodecache
    -
      debug: var=nodecache.stdout_lines
    -
      name: "Clearing the  Curam AppPrfiles osgi cache"
      shell: "{{ profile_home }}/osgiCfgInit.sh"
      when: '"The Node Agent \"nodeagent\" cannot be reached" in nodeagentstatus.stdout'
      register: nodecacheosgi
    -
      debug: var=nodecacheosgi.stdout_lines
    -
      shell: "{{ sync_util2 }} {{ dmgr_host2 }} {{ dmgr_port2 }} -username {{ dmgr_username2 }} -password {{ dmgr_password2 }}"
      ignore_errors: true
      name: "Sync the Curam node to deployment manager"
      when: '"The Node Agent \"nodeagent\" cannot be reached" in nodeagentstatus.stdout'
      register: nodesync
    -
      debug: var=nodesync.stdout_lines
    -
      name: "starting the Curam node agent"
      shell: "{{ startnode_util }}"
      when: '"The Node Agent \"nodeagent\" cannot be reached" in nodeagentstatus.stdout'
      register: startnode
    -
      debug: var=startnode.stdout_lines
    -
      name: "All Servers status"
      shell: "{{ profile_home }}/serverStatus.sh -all"
      register: allsrvstatus
    -
      debug: var=allsrvstatus.stdout_lines
    -
      name: "Messaging Server Status in messaging node-1"
      shell: "{{ appsrvbinlocation }}/serverStatus.sh Message"
      when:
        - '"Server name: Message" in allsrvstatus.stdout'
      register: messagesrvstatus1
    -
      debug: var=messagesrvstatus1.stdout_lines
    -
      name: "Starting Messaging Server in Messaging node-1"
      shell: "{{ appsrvbinlocation }}/startServer.sh Message"
      when:
        - '"Server name: Message" in allsrvstatus.stdout'
        - '"The Application Server \"Message\" cannot be reached." in messagesrvstatus1.stdout'
        - '"The Node Agent \"nodeagent\" is STARTED" in allsrvstatus.stdout'
      register: startmessagesrv1
    -
      debug: var=startmessagesrv1.stdout_lines
    -
      name: "Messaging Server Status in messaging node-2"
      shell: "{{ appsrvbinlocation }}/serverStatus.sh Message"
      when:
        - '"Server name: Message" in allsrvstatus.stdout'
      register: messagesrvstatus2
    -
      debug: var=messagesrvstatus2.stdout_lines
    -
      name: "Starting Messaging Server in Messaging node-2"
      shell: "{{ appsrvbinlocation }}/startServer.sh Message"
      when:
        - '"Server name: Message" in allsrvstatus.stdout'
        - '"The Application Server \"Message\" cannot be reached." in messagesrvstatus2.stdout'
        - '"The Node Agent \"nodeagent\" is STARTED" in allsrvstatus.stdout'
      register: startmessagesrv2
    -
      debug: var=startmessagesrv2.stdout_lines
    -
      name: "Assister Server Status in assister node-1"
      shell: "{{ appsrvbinlocation }}/serverStatus.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
      register: assistsrvstatus1
    -
      debug: var=assistsrvstatus1.stdout_lines
    -
      name: "Starting Assister Server in assister node-1"
      shell: "{{ appsrvbinlocation }}/startServer.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
        - '"The Application Server \"ASS\" cannot be reached." in assistsrvstatus1.stdout'
        - '"The Node Agent \"nodeagent\" is STARTED" in allsrvstatus.stdout'
      register: startassistsrv1
    -
      debug: var=startassistsrv1.stdout_lines
    -
      name: "Assister Server Status in assister node-2"
      shell: "{{ appsrvbinlocation }}/serverStatus.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
      register: assistsrvstatus2
    -
      debug: var=assistsrvstatus2.stdout_lines
    -
      name: "Starting Assister Server in assister node-2"
      shell: "{{ appsrvbinlocation }}/startServer.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
        - '"The Application Server \"ASS\" cannot be reached." in assistsrvstatus2.stdout'
        - '"The Node Agent \"nodeagent\" is STARTED" in allsrvstatus.stdout'
      register: startassistsrv2
    -
      debug: var=startassistsrv2.stdout_lines
    -
      name: "Assister Server Status in assister node-3"
      shell: "{{ appsrvbinlocation }}/serverStatus.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
      register: assistsrvstatus3
    -
      debug: var=assistsrvstatus3.stdout_lines
    -
      name: "Starting Assister Server in assister node-3"
      shell: "{{ appsrvbinlocation }}/startServer.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
        - '"The Application Server \"ASS\" cannot be reached." in assistsrvstatus3.stdout'
        - '"The Node Agent \"nodeagent\" is STARTED" in allsrvstatus.stdout'
      register: startassistsrv3
    -
      debug: var=startassistsrv3.stdout_lines
    -
      name: "Assister Server Status in assister node-4"
      shell: "{{ appsrvbinlocation }}/serverStatus.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
      register: assistsrvstatus4
    -
      debug: var=assistsrvstatus4.stdout_lines
    -
      name: "Starting Assister Server in assister node-4"
      shell: "{{ appsrvbinlocation }}/startServer.sh ASS"
      when:
        - '"Server name: ASS" in allsrvstatus.stdout'
        - '"The Application Server \"ASS\" cannot be reached." in assistsrvstatus4.stdout'
        - '"The Node Agent \"nodeagent\" is STARTED" in allsrvstatus.stdout'
      register: startassistsrv4
    -
      debug: var=startassistsrv4.stdout_lines
  vars:
    -
      sync_util2: /opt/WebSphere/AppServer*/profiles/AppSrv*/bin/syncNode.sh
    -
      startnode_util: /opt/WebSphere/AppServer*/profiles/AppSrv*/bin/startNode.sh
    -
      profile_home: /opt/WebSphere/AppServer*/profiles/AppSrv*/bin
    -
      dmgr_host2: "{{ hostvars['XX.XXX.XX.X']['hostnameforcuramdmgr']['stdout'] }}"
    -
      dmgr_port2: 8879
    -
      dmgr_username2: wsadmin
    -
      dmgr_password2: ******
    -
      appsrvbinlocation: /opt/WebSphere/AppServer8.5.5/profiles/AppSrv*/bin

Rajesh Martha

no leída,
26 abr 2017, 9:09:4726/4/17
a Ansible Project
ISSUE TYPE

Need help in writing the ansible logic.

ANSIBLE VERSION

ansible 2.2.1.0
Hi All, I need Help for starting and Stopping the servers in WebSphere,
I have a 9 nodes in websphere, Node1 have 3 servers(Message, CW, CP), Node2 Have 3 servers((Message, CW, CP), Node3 have 2(CW, CP) servers, Node4 2 servers(CW, CP), Node5 have 3 servers(ASS, CW, WEB), Node6 have 3 servers(ASS, CW, WEB), Node7 have 3 serers(ASS, CW, WEB), Node 8 have 3 servers(ASS, CW, WEB), Node 9 have 1 servers(CW),

With My ansibel script, First I am staring Deployment Manager, then i sync the Nodes to deplyment manger if Dmanger running, if node sync successful then i am starting nodeagents,
if Nodeagents started successfully then i am starting server1(Message) on Node1 and 2,

Here i need to start the servers(ASS) on Node5, Node6, Node7 and Node8 if server(Message) started successfully on Node1 and Node2,

Here i need to start the Servers(WEB) on Node5, Node6, Node7 and Node8 if server(Message) started successfully on Node1 and Node2, and Server(ASS) started successfully on Node5, Node6, Node7 and Node8....

Can some one please help to write the code in Ansible, The script i have written are attached here,
i am also attaching my hostfile.

[ATST-CURAMDMGR]

xx.xxx.xx.1

[ATST-CURAMAPPSRV]

xx.xxx.xx.1

xx.xxx.xx.2

xx.xxx.xx.3

xx.xxx.xx.4

xx.xxx.xx.5

xx.xxx.xx.6

xx.xxx.xx.7

xx.xxx.xx.8

xx.xxx.xx.9


Yamal(Ansibel) script

Rajesh Martha

no leída,
27 abr 2017, 11:55:5527/4/17
a Ansible Project
is any body to help me? 

Rajesh Martha

no leída,
1 may 2017, 11:07:441/5/17
a Ansible Project
NO body knows how to write this script? 
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos