zmcontrol in ansible tasks

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
Post Reply
eristoff_ice
Posts: 2
Joined: Tue Jan 25, 2022 5:00 pm

zmcontrol in ansible tasks

Post by eristoff_ice »

Hi,
This is my first post here, sorry if it is the wrong section, if so just tell me and i will ask in another section.
I need to be able to restart my zimbra services throug an ansible task:

The task is this:

Code: Select all

- name: 'Restart Zimbra'
  become: true
  become_user: zimbra
  command: './zmcontrol restart'
  args:
    chdir: '/opt/zimbra/bin/'
but i get error for this services:
Host myhost.com
Starting zmconfigd...Done.
Starting mailbox...Done.
Starting snmp...Failed.
creating /opt/zimbra/conf/snmpd.conf
creating /opt/zimbra/conf/swatchrc
Starting swatch...failed.
Starting stats...Done.
Starting zimbra webapp...Done.
Starting zimbraAdmin webapp...Done.
Starting zimlet webapp...Done.
if i run the same command ( even more than one time ) manually it works flawlessy.

Do some of you have some ideas of why this happens ?
I tried searching in the /var/log/zimbra.log but it shows no errors

Thank You

my zimbra version is Release 8.7.9_GA_1794.RHEL7_64_20170505054622 RHEL7_64 NETWORK edition
my OS is centOS 7
User avatar
JDunphy
Outstanding Member
Outstanding Member
Posts: 897
Joined: Fri Sep 12, 2014 11:18 pm
Location: Victoria, BC
ZCS/ZD Version: 9.0.0_P39 NETWORK Edition

Re: zmcontrol in ansible tasks

Post by JDunphy »

It isn't tty/ptty related as we do it all the time from cron with LE certs that need a restart... Has to be environmental as a lot of stuff is setup with .bashrc

Perhaps:

Code: Select all

- name: 'Restart Zimbra Services'
  shell: source /opt/zimbra/.bashrc && ./zmcontrol restart
  args:
    executable: /bin/bash
    chdir: '/opt/zimbra/bin/'
  become: yes
  become_user: zimbra
  retries: 3
Jim
ghen
Outstanding Member
Outstanding Member
Posts: 259
Joined: Thu May 12, 2016 1:56 pm
Location: Belgium
ZCS/ZD Version: 9.0.0

Re: zmcontrol in ansible tasks

Post by ghen »

Why not just "service: name=zimbra state=restarted" (as root) ?
eristoff_ice
Posts: 2
Joined: Tue Jan 25, 2022 5:00 pm

Re: zmcontrol in ansible tasks

Post by eristoff_ice »

JDunphy wrote:It isn't tty/ptty related as we do it all the time from cron with LE certs that need a restart... Has to be environmental as a lot of stuff is setup with .bashrc

Perhaps:

Code: Select all

- name: 'Restart Zimbra Services'
  shell: source /opt/zimbra/.bashrc && ./zmcontrol restart
  args:
    executable: /bin/bash
    chdir: '/opt/zimbra/bin/'
  become: yes
  become_user: zimbra
  retries: 3
Jim
Thank You very much It works now, i was really stuck on this one.
ghen wrote:Why not just "service: name=zimbra state=restarted" (as root) ?
I don't know why actually, i just need to restart services after uploading the new SSL certs and I found someware that this was the final step of the procedure. Is it the same if i use the service zimbra restart command ?
Post Reply