start servers using ansible playbook

14 views
Skip to first unread message

Cloud09

unread,
Feb 3, 2020, 8:56:33 PM2/3/20
to ansible...@googlegroups.com
Hello Team,

I am writing a playbook to start weblogic servers, could anyone help me any syntax errors, I could not make item/item display as it should be, or please feel free to correct me here if any incorrect syntax and would not work as expected.

---
          - hostsappservers
            becomeyes
            become_usercloud9
            vars:
              filepath:
                - "nohup /opt/jpmc/cloud9/stat/wl12213/cloud9/bin"
              stopservers:
                - "/stop-caServer01.sh"
                - "/stop-nyServer01.sh"
                - "/stop-ohServer01.sh"
            tasks:
              - nameStart the admin server
                command"{{item}}/startManagedWebLogic.sh"
              loop:
                - filepath 
              - nameStart the managed server(s)
                command"{{item}}/{{item}}"
            loop
              - filepath
              - stopservers

James Cassell

unread,
Feb 4, 2020, 12:04:07 AM2/4/20
to Ansible List
Instead of loop, I'd recommend with_together.

- name: Start the managed server(s)
command: "{{item.0}}/{{item.1}}"
with_together:
- "{{filepath}}"
- "{{stopservers}}"

V/r,
James Cassell

James Cassell

unread,
Feb 4, 2020, 12:08:00 AM2/4/20
to Ansible List
Actually it's much simpler for your example:


- name: Start the managed server(s)
command: "{{filepath}}/{{item}}"
loop: "{{stopservers}}"

V/r,
James Cassell

Cloud09

unread,
Feb 4, 2020, 5:41:42 AM2/4/20
to ansible...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ebfb0e3c-b7e5-42c7-a4a4-aaa20c9c85ff%40www.fastmail.com.
Reply all
Reply to author
Forward
0 new messages