관리-도구
편집 파일: sysvinit.cpython-39.opt-1.pyc
a �)g�5 � @ s~ d dl mZmZmZ eZdZdZdZd dl Z d dl mZ d dlm Z d dlmZmZmZmZmZmZ d d � Zedkrze� dS )� )�absolute_import�division�print_functiona� module: sysvinit author: - "Ansible Core Team" version_added: "2.6" short_description: Manage SysV services. description: - Controls services on target hosts that use the SysV init system. options: name: required: true description: - Name of the service. type: str aliases: ['service'] state: choices: [ 'started', 'stopped', 'restarted', 'reloaded' ] description: - C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. Not all init scripts support C(restarted) nor C(reloaded) natively, so these will both trigger a stop and start as needed. type: str enabled: type: bool description: - Whether the service should start on boot. B(At least one of state and enabled are required.) sleep: default: 1 description: - If the service is being C(restarted) or C(reloaded) then sleep this many seconds between the stop and start command. This helps to workaround badly behaving services. type: int pattern: description: - 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 running. - "This option is mainly for use with init scripts that don't support the 'status' option." type: str runlevels: description: - The runlevels this script should be enabled/disabled from. - Use this to override the defaults set by the package or init script itself. type: list elements: str arguments: description: - Additional arguments provided on the command line that some init scripts accept. type: str aliases: [ 'args' ] daemonize: type: bool description: - Have the module daemonize as the service itself might not do so properly. - This is useful with badly written init scripts or daemons, which commonly manifests as the task hanging as it is still holding the tty or the service dying when the task is over as the connection closes the session. default: no extends_documentation_fragment: action_common_attributes attributes: check_mode: support: full diff_mode: support: none platform: platforms: posix notes: - One option other than name is required. - The service names might vary by specific OS/distribution requirements: - That the service managed has a corresponding init script. a: - name: Make sure apache2 is started ansible.builtin.sysvinit: name: apache2 state: started enabled: yes - name: Make sure apache2 is started on runlevels 3 and 5 ansible.builtin.sysvinit: name: apache2 state: started enabled: yes runlevels: - 3 - 5 az results: description: results from actions taken returned: always type: complex sample: { "attempts": 1, "changed": true, "name": "apache2", "status": { "enabled": { "changed": true, "rc": 0, "stderr": "", "stdout": "" }, "stopped": { "changed": true, "rc": 0, "stderr": "", "stdout": "Stopping web server: apache2.\n" } } } N)�sleep)� AnsibleModule)�sysv_is_enabled�get_sysv_script�sysv_exists�fail_if_missing�get_ps� daemonizec s� t ttdddgd�tg d�dd�tdd�td d d�tdd�tddgd �tddd�tddd�d�dddggd���jd ��jd � �jd } �jd }�jd }�jd }d}d }}�di d�}t�t���� t���g d�}g d�} i } i }| D ]}�j||d�||<