o nnho@srddlmZdZdZdZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZedkr@ddlmZddlmZmZdd lmZdd lmZdd lmZdd lmZmZdd lmZm Z Gddde!Z"Gddde"Z#Gddde"Z$Gddde$Z%Gddde"Z&Gddde"Z'Gddde"Z(Gddde"Z)ddZ*e+d kre*dSdS)!) annotationsa1 --- module: service version_added: "0.1" short_description: Manage services description: - Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart. - This module acts as a proxy to the underlying service manager module. While all arguments will be passed to the underlying module, not all modules support the same arguments. This documentation only covers the minimum intersection of module arguments that all service manager modules support. - This module is a proxy for multiple more specific service manager modules (such as M(ansible.builtin.systemd) and M(ansible.builtin.sysvinit)). This allows management of a heterogeneous environment of machines without creating a specific task for each service manager. The module to be executed is determined by the O(use) option, which defaults to the service manager discovered by M(ansible.builtin.setup). If M(ansible.builtin.setup) was not yet run, this module may run it. - For Windows targets, use the M(ansible.windows.win_service) module instead. options: name: description: - Name of the service. type: str required: true state: description: - V(started)/V(stopped) are idempotent actions that will not run commands unless necessary. - V(restarted) will always bounce the service. - V(reloaded) will always reload. - B(At least one of state and enabled are required.) - Note that reloaded will start the service if it is not already started, even if your chosen init system wouldn't normally. type: str choices: [ reloaded, restarted, started, stopped ] sleep: description: - If the service is being V(restarted) then sleep this many seconds between the stop and start command. - This helps to work around badly-behaving init scripts that exit immediately after signaling a process to stop. - Not all service managers support sleep, i.e when using systemd this setting will be ignored. type: int version_added: "1.3" pattern: description: - If the service does not respond to the status command, name a substring to look for as would be found in the output of the I(ps) command as a stand-in for a status result. - If the string is found, the service will be assumed to be started. - While using remote hosts with systemd this setting will be ignored. type: str version_added: "0.7" enabled: description: - Whether the service should start on boot. - B(At least one of state and enabled are required.) type: bool runlevel: description: - For OpenRC init scripts (e.g. Gentoo) only. - The runlevel that this service belongs to. - While using remote hosts with systemd this setting will be ignored. type: str default: default arguments: description: - Additional arguments provided on the command line. - While using remote hosts with systemd this setting will be ignored. type: str default: '' aliases: [ args ] use: description: - The service module actually uses system specific modules, normally through auto detection, this setting can force a specific module. - Normally it uses the value of the 'ansible_service_mgr' fact and falls back to the old 'service' module when none matching is found. - The 'old service module' still uses autodetection and in no way does it correspond to the C(service) command. type: str default: auto version_added: 2.2 extends_documentation_fragment: - action_common_attributes - action_common_attributes.flow attributes: action: support: full async: support: full bypass_host_loop: support: none check_mode: details: support depends on the underlying plugin invoked support: N/A diff_mode: details: support depends on the underlying plugin invoked support: N/A platform: details: The support depends on the availability for the specific plugin for each platform and if fact gathering is able to detect it platforms: all notes: - For AIX, group subsystem names can be used. - The C(service) command line utility is not part of any service manager system but a convenience. It does not have a standard implementation across systems, and this action cannot use it directly. Though it might be used if found in certain circumstances, the detected system service manager is normally preferred. seealso: - module: ansible.windows.win_service author: - Ansible Core Team - Michael DeHaan a9 - name: Start service httpd, if not started ansible.builtin.service: name: httpd state: started - name: Stop service httpd, if started ansible.builtin.service: name: httpd state: stopped - name: Restart service httpd, in all cases ansible.builtin.service: name: httpd state: restarted - name: Reload service httpd, in all cases ansible.builtin.service: name: httpd state: reloaded - name: Enable service httpd, and not touch the state ansible.builtin.service: name: httpd enabled: yes - name: Start service foo, based on running process /usr/bin/foo ansible.builtin.service: name: foo pattern: /usr/bin/foo state: started - name: Restart network service for interface eth0 ansible.builtin.service: name: network state: restarted args: eth0 #NSunOS) LooseVersion)to_bytesto_text) AnsibleModule)get_best_parsable_locale)get_platform_subclass)fail_if_missingis_systemd_managed)PY2bcszeZdZdZdZdZfddZddZdd Zd d Z d d Z ddZ dddZ ddZ ddZddZddZZS)ServiceaT This is the generic Service manipulation class that is subclassed based on platform. A subclass should override the following action methods:- - get_service_tools - service_enable - get_service_status - service_control All subclasses MUST define platform and distribution (which may be None). GenericNcstt}t|||S)N)r rsuper__new__)clsargskwargsnew_cls __class__B/usr/local/lib/python3.10/dist-packages/ansible/modules/service.pyrszService.__new__cCs||_|jd|_|jd|_|jd|_|jd|_|jd|_|jd|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_|jdd |_d|_d|_d|_d|_dS) NnamestatesleeppatternenabledrunlevelF arguments)moduleparamsrrrrenabler changedrunningcrashedactionsvc_cmdsvc_initscript svc_initctl enable_cmdgetr! rcconf_file rcconf_key rcconf_value svc_change)selfr#rrr__init__s(       zService.__init__cC|jjdddS)Nz4get_service_tools not implemented on target platformmsgr# fail_jsonr3rrrget_service_toolszService.get_service_toolscCr5)Nz1service_enable not implemented on target platformr6r8r:rrrservice_enabler<zService.service_enablecCr5)Nz5get_service_status not implemented on target platformr6r8r:rrrget_service_statusr<zService.get_service_statuscCr5)Nz2service_control not implemented on target platformr6r8r:rrrservice_controlr<zService.service_controlFc st|j}t|||d}|s|jj||dStt}|dkr7tdttj tj }|dkr'sz+Service.execute_command..FcstdS)NrD)oscloserpiperr,sz)Service.execute_command..)shellstdoutstderrenv preexec_fnr"izunable to forkr6)'r r#dict run_commandrMrPforkrNopendevnullO_RDWRdup2_exitsetsidchdirr rshlexsplitr subprocessPopenPIPErrSrTselectpollreadfilenoremovewaitjsondumps returncodewriter9waitpidloads)r3cmd daemonizelocalelang_envpidfdprSrTfdsrfdwfdefddatblobdatarrOrexecute_commands            "        zService.execute_commandcCstdkr d}nd}|jdd}|d||f\}}}|dkr>d|_|d }|D]}|j|vr=d |vr=d|_dSq,dSdS) Nrz-efauxwwpsT%s %srF zpattern=)platformsystemr# get_bin_pathrr'rcr)r3psflagspsbinrcpsoutpserrlineslinerrrcheck_psUs  zService.check_pscCs|jr|jdur|jjdd|js|jdvrd|_n|jr'|jdvr'd|_n|jdkr/d|_|jjr@|jrB|jjddddSdSdS) Nz@failed determining service state, possible typo of service name?r6)reloadedstartedT)rstopped restartedzservice state changedr&r7)rr'r#r9r2 check_mode exit_jsonr:rrrcheck_service_changedjs zService.check_service_changedcCs|jrB|jdvr d|_n&|js|jdkrd|_n|jdkr!d|_n|jdkr*d|_n|jdkr2d|_|jjr>|jjd d d |Sd }d }d }|||fS)N)rstartrrstopreloadrrestartTzchanging service staterrr")r2rr)r'r#rrr?)r3rerroutrrrmodify_service_statews$     zService.modify_service_statec Cs|jdus|jdus|jdur|jjddd|_d|j|jf}t|jdK}g}|D]>}tj|dd}t |dkrad|d vra|d dd\}}||jkra| |jkr\d |_n|}d|_| | d q,Wdn1suwY|jdur| |d|_|jdur|jj r|jjdd d tj|j}tj|j} tj|d| d\} } |D] }t| |qt| |j| |jdSdS)NzIservice_enable_rcconf() requires rcconf_file, rcconf_key and rcconf_valuer6z%s="%s" rTcommentsrD=rFrchanging service enablementrz%s-)dirprefix)r/r0r1r#r9r&r[rbrclenupperappendstriprrrMpathdirnamebasenametempfilemkstemprpencoderN atomic_move) r3entryRCFILE new_rc_confrclinercarraykeyvalue rcconf_dir rcconf_base TMP_RCCONFtmp_rcconf_filerrrservice_enable_rcconfsB     zService.service_enable_rcconf)F)__name__ __module__ __qualname____doc__r distributionrr4r;r=r>r?rrrrr __classcell__rrrrrs   ^ rc@sPeZdZdZdZdZddZddZdd Zd d Z d d Z ddZ ddZ dS) LinuxServicez This is the Linux Service manipulation class - it is currently supporting a mixture of binaries and init scripts for controlling services started at boot, as well as for controlling the current state. LinuxNc s(gd}gd}dg}t|D] }jj||d|<q|D]}d|jf}tj|r1|_qfdd}|rKj_d_ d_ n d d rtj d jrd _ t d _z(td }jdd \} } } | dkr|| } | rt | d_Wn tyYnwd _ n8 dd rd_ d_ dSjrԈ dd rd_ n ddrɈd_ n dd rԈd_ j durtjd jddj dur dd rd_ j durjsjjdd d d rd _dSdS)N)z/sbinz /usr/sbinz/binz/usr/bin) service chkconfig update-rc.d rc-service rc-updateinitctl systemctlrrrinsservz /etc/init.d)opt_dirs%s/%scsddr tjSdS)NrF)r.r r#rlocationr3rr check_systemds  z5LinuxService.get_service_tools..check_systemdrrFz/etc/init/%s.confz0.0.0z\(upstart (.*)\)z %s versionrrrrrrhostr6rzbcannot find 'service' binary or init script for service, possible typo in service name?, aborting)rXr#rrrMrisfiler+_LinuxService__systemd_unitr*r-r.existsrupstart_versionrecompilerYsearchgroups Exceptionr r9r,) r3pathsbinaries initpathsbinaryinitdir initscriptr version_rerrSrTresrrrr;sf                    zLinuxService.get_service_toolscCs^dd}dd}|j}|d|j|f\}}}|dkrdS|dr%d S||r-||Sd S) NcSsd|}t|tjS)Nz /etc/init.d/)rMaccessX_OK)rscriptrrr sysv_exists#sz=LinuxService.get_systemd_service_enabled..sysv_existscSsttd|S)N/etc/rc?.d/S??)boolglob)rrrrsysv_is_enabled'r<zALinuxService.get_systemd_service_enabled..sysv_is_enabledz%s is-enabled %srTdisabledF)rrr- startswith)r3rr service_namerrrrrrget_systemd_service_enabled"s z(LinuxService.get_systemd_service_enabledc Cs|d|j|jf\}}}|dkr |jjd||j|fdnd|vr0|jjd|j|fdd}g}i}|D]N}d|vr|sl|dd\}}|d re| d r_|||<d}q:| |q:|||<d}q:| d r}d |||<d}q:| |q:| |q:|S) Nz %s show '%s'rz,failure %d running systemctl show for %r: %sr6zLoadState=not-foundz5systemd could not find the requested service "%r": %srrD{}r) rr-rr#r9 splitlinesrclstriprrstripendswithrjoin) r3rrrr value_buffer status_dictrrrrrget_systemd_status_dict5s2    z$LinuxService.get_systemd_status_dictcCs|}|ddkrd|_d|_|jS|ddkr$d|_d|_|jS|ddur9|jjd|jfd|jSd|_d|_|jS)N ActiveStateactiveTFfailedz4No ActiveState value in systemctl show output for %rr6)rr.r'r(r#r9r)r3drrrget_systemd_service_status]s z'LinuxService.get_systemd_service_statusc Cs|jr |jdr |Sd|_|\}}}|jr>|jdur>|d|j|j|j f\}}}d|vr7d|_nd|vr>d|_|jrd|jdrd|jdurd|d |j|jf\}}} d |v|_d | v|_ |jdurp|d vrpd|_|jdur| d dkr| |j d} d| vrd|_n5d| vrd| v|_n+d| vrd| vrd|_nd| vrd|_nd| vrd|_nd| vrd|_nd| vrd|_|jdur|dkrd|_|jdur|jdkrd|vrd|_|jS)Nrstatusz%s status %s %sz stop/waitingFz start/runningTrz %s %s statusrr()rDrEErrDr"rrunznot rzcould not access pid filezis dead and pid file existszdead but subsys lockedzdead but pid file existsriptablesACCEPT)r*rrr)r?r,r'rrr!r(countlowerreplace) r3r status_stdout status_stderr initctl_rcinitctl_status_stdoutinitctl_status_stderr openrc_rcopenrc_status_stdoutopenrc_status_stderrcleanoutrrrr>osL     zLinuxService.get_service_statuscCs:|jdur|jjd|jdd|_d}|jdrdd}d}|jtdkr4t d tj tj B}d }n t d tj tj B}d }d ||jf}d||jf}t | }| } Wdn1sawY|| rr|jjddd|_tj|rt | } | } Wdn1swY|jr|| rd|_|d| } n|js|| sd|_d| |f} n n |jsd|_|} n |jjr|jj|jd|jrz||| WdSty|jjddYdSwdS|jdrP|jrd}nd}|d|j|jf\} }}d|j|vr-|d|j|jf|d|j|jf\} }}|j|vr=|jjd|jdd||vrPd||vrPd|_dS|jdro|jr^d}nd }|}|j|krod|_dS|jd!r|jr}d"}nd#}|d$|j\} }}|D]7}|d%\}}|}||jkrqtd&|}|jr|j|vrd|_n |js|j|vrd|_n|jsd|_|jsdS|jd'rqd}td(|j}|rd}|j|krld|_|jr5d}td)|j}|s4|jjs4|d*|j|jf\} }}| d+kr4|r&|jj|dn|jj|d|j|j|fnd }|jjsj|d,|j|j|f\} }}| d+krj|r\|jj|ddS|jj|d|j|j|fdSd|_dS|jd-r/|jr|d.|j|jf\} }}n|d/|j|jf\} }}d|_|D]%}|jr|d0d1krd|_n|js|d2d1krd|_nq|jjr|jj|jd|jsdS|jr|d3|j|jf\} }}| d+ks|dkr|jjd4| ||fd| ||fS|d5|j|jf\} }}| d+ks|dkr*|jjd6| ||fd| ||fSd|_|jd!rF|j||jd7|jf}n|jdrU|j||j f}n|j|j|f}|jjri|jj|jd|d,|\} }}| d+kr|r|jjd8||j| |fdn|jjd9||j| |fd| ||fS):NzScannot detect command to enable service %s, typo or init system potentially unknownr6TrcSs t|d}|||dS)Nw)r[rprN) file_name file_contents override_filerrrwrite_to_override_files   z;LinuxService.service_enable..write_to_override_filez /etc/initz0.6.7z ^manual\s*$zmanual z^start on manual\s*$zstart on manual z %s/%s.confz%s/%s.overridez+manual stanza not supported in a .conf fileFr"r)r&zCould not modify override fileronoffz %s --list %szchkconfig --add %sz %s --add %sz%service %s does not support chkconfigz3:%sz5:%srr%disableradddeletez%s show|z\s+rrz/etc/rc?.d/K??z%s %s defaultsr%s %s %srz %s -n -v %sz%s -n -r -v %szenable servicerWzremove servicerz3Failed to install service. rc: %s, out: %s, err: %sz%s -r %sz2Failed to remove service. rc: %s, out: %s, err: %s z$Error when trying to %s %s: rc=%s %szFailure for %s %s: rc=%s %s)!r-r#r9rr&rrrrrMIr[rirrMrrr%subrrrrrrrrcrr rfindr)r3r)rinitpathmanreg config_lineconf_file_nameoverride_file_name conf_file_fhconf_file_content override_fhoverride_file_contentsoverride_staterrrservice_enabledrr runlevelsrslinksklinksrrrrr=s8                           zLinuxService.service_enablec Cs&d}|j}|jr3|jds(|jdr|j}d|j|f}n!d|j|jf}n|j}d|j|f}n |jdur@|jr@d|j}|jrZ|jdrZ|jdkrZ|jrZ|jd|d d |jd kr|dkrt|jd ||j|fd d \}}}n|jd |j|j|fd d \}}}n|jr|jdr|jd ||j|fd d \}}}nn|dkr|jd |d |fd d \}}}n|jd d |j|fd d \}}}|j rt |j |dkr|jd |d|fd d \} } } n|jd d|j|fd d \} } } |dkr| dkr| }| }| }n || }|| }|| }|||fS)Nr"rrr%srrz%s zapTrtrrrr) r!r*rrrr+r)r(rrtime) r3r*r!rc_staterSrTrc1stdout1stderr1rc2stdout2stderr2rrrr?sH   " "$"      zLinuxService.service_control) rrrrrrr;rrrr>r=r?rrrrrsN(> trc@8eZdZdZdZdZddZddZdd Zd d Z dS) FreeBsdServicez This is the FreeBSD Service manipulation class - it uses the /etc/rc.conf file for controlling services started at boot and the 'service' binary to check status and perform direct service manipulation. FreeBSDNcCs6|jdd|_|js|jjdd|jd|_dS)NrTzunable to find service binaryr6sysrc)r#rr*r9 sysrc_cmdr:rrrr;sz FreeBsdService.get_service_toolscCsb|d|j|jd|jf\}}}|jdkrd|v|_dS|dkr&d|_dS|dkr/d|_dSdS) N %s %s %s %s onestatuspfEnabledrDFrT)rr*rr!r'r3rrSrTrrrr>s"   z!FreeBsdService.get_service_statuscCs|jrd|_nd|_gd}|D] }tj|r||_q|d|j|jd|j f\}}}z t j |dd}Wn t y?Ynw|sK|j jd||d |D]}d |vr^| d d \|_}nqM|jdurm|j jd||d |jr|d |j|jf\}} }|d kr|} | |jkrd|_|j jr|j jddd|d|j|j|jf\}} } |d kr|j jd| | d |d|j|jdf\}} } |j|d kkr|j jd| | d dSdSd|_dSz|WSt y|j jddYdSw)NYESNO) /etc/rc.confz/etc/rc.conf.localz/usr/local/etc/rc.confrArcvarTrzunable to determine rcvar)r7rSrTrrDz%s -n %srrrz %s %s="%s"zunable to set rcvar using sysrcrrz/unable to set rcvar: sysrc did not change valueFzunable to set rcvarr6)r%r1rMrrr/rr*rr!rbrcrr#r9r0r@rrr&rrr)r3rcfilesrcfilerrSrTrcvarsrIdefault_rcconf_valuecurrent_rcconf_value change_stdout change_stderr check_stdout check_stderrrrrr=sX "      zFreeBsdService.service_enablecCsd|jdkrd|_|jdkrd|_|jdkrd|_|d|j|j|j|jf}|jr0t|j|S)Nronestartronestopr onereloadrA)r)rr*rr!rr4)r3retrrrr?Cs    zFreeBsdService.service_control) rrrrrrr;r>r=r?rrrrr=s Cr=c@s eZdZdZdZdZddZdS)DragonFlyBsdServicez This is the DragonFly BSD Service manipulation class - it uses the /etc/rc.conf file for controlling services started at boot and the 'service' binary to check status and perform direct service manipulation. DragonFlyNcCR|jrd|_nd|_dg}|D] }tj|r||_qd|jdd|_| SNrFrGrHr2-_ r%r1rMrrr/rr r0rr3rJrKrrrr=^ z"DragonFlyBsdService.service_enable)rrrrrrr=rrrrrWTs  rWcs@eZdZdZdZdZddZddZdd Zfd d Z Z S) OpenBsdServicez This is the OpenBSD Service manipulation class - it uses rcctl(8) or /etc/rc.d scripts for service control. Enabling a service is only supported if rcctl is present. OpenBSDNcCs^|jd|_|jr|j|_nd}d||jf}tj|r!||_|js-|jjdddSdS)Nrcctl /etc/rc.drzunable to find svc_cmdr6) r#rr-r*rrMrrr9)r3rcdir rc_scriptrrrr;xs  z OpenBsdService.get_service_toolscCsz|jr|d|jd|jf\}}}n |d|jdf\}}}|r)|jj|d|dkr2d|_dS|dkr;d|_dSdS) Nrcheckrr6rDFrT)r-rr*rr#r9r'rErrrr>s   z!OpenBsdService.get_service_statuscCs:|jr|jd|j|j|jfddS|d|j|jfS)Nz %s -f %s %sTr3z%s -f %s)r-rr*r)rr:rrrr?szOpenBsdService.service_controlcs|js tt|S|d|jd|jdf\}}}d}|jr&|dkr%d}n |jdur1|dkr1d}|durcd|_|jj se|d |j|j|f\}}}|dkrg|rZ|jj |d dS|jj d d dSdSdSdS) NrAr.rrrrDrTz%s set %s status %sr6z%rcctl failed to modify service status) r-rr`r=rrr%r&r#rr9)r3rrSrT status_actionrrrr=s,  zOpenBsdService.service_enable) rrrrrrr;r>r?r=rrrrrr`nsr`c@r<) NetBsdServicea> This is the NetBSD Service manipulation class - it uses the /etc/rc.conf file for controlling services started at boot, check status and perform direct service manipulation. Init scripts in /etc/rc.d are used for controlling services (start/stop) as well as for controlling the current state. NetBSDNcCsLdg}|D]}d||jf}tj|r||_q|js$|jjdddSdS)Nrcrzunable to find rc.d scriptr6)rrMrrr+r#r9)r3rrrrrrr;s zNetBsdService.get_service_toolscCrYrZr]r^rrrr=r_zNetBsdService.service_enablecCsNd|j|_|d|jdf\}}}|dkrd|_dS|dkr%d|_dSdS)Nr2rrBrDFrT)r+r*rr'rErrrr>s   z NetBsdService.get_service_statuscCsF|jdkrd|_|jdkrd|_d|j|_|jd|j|jfddS) NrrSrrTr2rTr3)r)r+r*rr:rrrr?s   zNetBsdService.service_control) rrrrrrr;r=r>r?rrrrrhs  rhc@sHeZdZdZdZdZddZddZdd Zd d Z d d Z ddZ dS) SunOSServicez This is the SunOS Service manipulation class - it uses the svcadm command for controlling services, and svcs command for checking status. It also tries to be smart about taking the service out of maintenance state if necessary. rNcCsd|jdd|_|js|jjdd|jdd|_|js$|jjdd|r-d|_dSd|_dS) NsvcsTzunable to find svcs binaryr6svcadmzunable to find svcadm binary-sr")r#rsvcs_cmdr9 svcadm_cmdsvcadm_supports_sync svcadm_syncr:rrrr;s  zSunOSService.get_service_toolscCs>tddD]}td|}|r|dkrdSqdS)Nz /etc/releaserz \s+Oracle Solaris (\d+)\.(\d+).*)112T)r[ readlinesrmatchrr)r3rmrrrrp s z!SunOSService.svcadm_supports_synccC$|}|dkr d|_dSd|_dS)NonlineTF)get_sunos_svcs_statusr'r3rrrrr>  zSunOSService.get_service_statuscCsl|d|j|jf\}}}|dkr#|r|jj|dn|jj|d|dd}|ddd}|S)NrrDr6rrWrr)rrnrr#r9rrc)r3rrSrTrrrrrrysz"SunOSService.get_sunos_svcs_statusc Cs|d|j|jf\}}}|dkr#|r|jj|dn|jj|dd}d}|dD]}|dr?d|vr9d}d |vr?d}q,|rE| pI| oI|}|jrQ|rQdS|jsX|sXdS|jjs|jrbd }nd }|d |j ||jf\}}}|dkr|r|jj|dn|jj|dd|_ dS) Nz%s -l %srr6FrrtrueT temporaryz enable -rsz disable -sr) rrnrr#r9rcrr%rror&) r3rrSrTrr}rstartup_enabledsubcmdrrrr=(s:    zSunOSService.service_enablecCs|}|jdvr(|dvr(|d|j|jf\}}}|dkr$|||fS|}|dvr5|jjd|d|jdkr=d}n-|jd krEd }n%|jd krPd |j}n|jd kr_|dkr_d|j}n |jd krj|dkrjd}|d|j||jfS)N)rrr) maintenancedegradedz %s clear %srz)Failed to bring service out of %s status.r6rz enable -rstrz disable -strz refresh %srrxz restart %sr)ryr)rrorr#r9rq)r3rrrSrTrrrrr?Zs&      zSunOSService.service_control) rrrrrrr;rpr>ryr=r?rrrrrjs  2rjc@s8eZdZdZdZdZddZddZddZd d Z dS) AIXa This is the AIX Service (SRC) manipulation class - it uses lssrc, startsrc, stopsrc and refresh for service control. Enabling a service is currently not supported. Would require to add an entry in the /etc/inittab file (mkitab, chitab and rmitab commands) NcCs|jdd|_|js|jjdd|jdd|_|js$|jjdd|jdd|_|js6|jjdd|jd d|_|jsJ|jjd ddSdS) NlssrcTzunable to find lssrc binaryr6startsrczunable to find startsrc binarystopsrczunable to find stopsrc binaryrefreshzunable to find refresh binary)r#r lssrc_cmdr9 startsrc_cmd stopsrc_cmd refresh_cmdr:rrrr;szAIX.get_service_toolscCrw)NrTF)get_aix_src_statusr'rzrrrr>r{zAIX.get_service_statuscCs|d|j|jf\}}}|dkr^|d|j|jf\}}}|dkr8|r/|jj|ddS|jj|ddS|}|ddD]}|ddkrY|d}|SqBd}|S|dd}|ddd}|S) Nz%s -s %srDz%s -g %sr6rWrrr) rrrr#r9rrcrr)r3rrSrTrrrrrrrs&zAIX.get_aix_src_statusc Csj|d|j\}}}|dkr!|r|jj|dnD|jj|dn<|}g}g}|ddD]}|d}|d} ||| rM|| q/|j|vrVd} n|j|vr]d} |j dkrf|j } n/|j dkro|j } n&|j d krx|j } n|j d kr|d |j | |jf|j rt |j |j } |jr|j d vr|d | |j| |jfS|d | | |jfS)Nz%s -arDr6rrmz-grrrrr)rrz%s -a "%s" %s %s)rrr#r9rrcrrrr)rrrrr4r!) r3rrSrTr subsystemsrr subsystemgroupsrccmd_parametersrccmdrrrr?sB         zAIX.service_control) rrrrrrr;r>rr?rrrrrus rc Cstttdddtdgddtddtddtddtdd d tdd d gd ddddggd}t|}|d|j|jrG|d|jd}d }d }i}|j|d<||jj dduri| |j |d<|j ddur}|j |d<|j di||j|d<|jr|n|||\}}}|dkr|rd|vrn|r|j|dn|j|d|j |jB|d<|jj ddur|jj d|d<|jj ds|}|durd|d<n|durd|d<nd|d<n|jj ddvrd|d<nd|d<|j di|dS)NstrT)typerequired)rrrr)rchoicesint)rrdefault)rrr"r)rraliases)rrrrrr r!rr) argument_specsupports_check_moderequired_one_ofz"Service instantiated - platform %sz&Service instantiated - distribution %srrr&zJob is already runningr6absentFrr)rrrr)rrXrdebugrrrr;r#r$r=r%r&rrrrr>rrr9r2)r#rrrrresultrrrrmainsn               r__main__), __future__r DOCUMENTATIONEXAMPLESRETURNrrmrMrrrgrbrdrr4r#ansible.module_utils.compat.versionr+ansible.module_utils.common.text.convertersrransible.module_utils.basicr"ansible.module_utils.common.localer $ansible.module_utils.common.sys_infor ansible.module_utils.servicer r ansible.module_utils.sixr robjectrrr=rWr`rhrjrrrrrrrsR n'     oI8y[