How to manage services in ansible?



  • Link: http://docs.ansible.com/ansible/service_module.html

    Start

    $ ansible perth -b -m service -a "name=nginx state=started"
    ip-xxxx.us-west-2.compute.internal | SUCCESS => {
        "changed": true, 
        "name": "nginx", 
        "state": "started"
    

    Stop

    $ ansible perth -b -m service -a "name=nginx state=stopped"
    ip-xxxx.us-west-2.compute.internal | SUCCESS => {
        "changed": true, 
        "name": "nginx", 
        "state": "stopped"
    }
    

    Restarted

    $ ansible perth -b -m service -a "name=nginx state=restarted"
    ip-xxxx.us-west-2.compute.internal | SUCCESS => {
        "changed": true, 
        "name": "nginx", 
        "state": "started"
    }
    

Log in to reply
 

© Lightnetics 2024