Site icon techbeatly

ansible-tower-service, Start or Stop Ansible Tower

Image: rockwellcollins.com | 01 Jan 2000 — Hand on throttle — Image by © Firefly Productions/CORBIS

Learn Ansible : Automation with Ansible – All You Want to Learn

Ansible Tower is a wonderful product which help to implement a central hub for IT automation. Ansible Tower is basically a web console and REST API for underlying Ansible Engine but with more features and acts as centralised system with logging and RBAC (Role Based Access Control).

Read : How to backup and restore Ansible Tower configuration ?

As we know, Ansible Tower is a multi-component system including Ansible, Tower API, RabbitMQ, Database (managed or external) etc. And will be more complicated when you install Ansible Tower Cluster (multi-node or multi-data center clusters).

So, what if you need to stop Ansible Tower gracefully, for some reason (patching or some reason) and start components again ?

ansible-tower-service utility

Simple, Ansible Tower is coming with an utility script called ansible-tower-service and you can use it for starting/stopping/restarting the Ansible Tower system.

Also read How to Install Custom Modules in Ansible.

[root@node01-ansible ~]# ansible-tower-service -h
Ansible Tower service helper utility
Usage: /bin/ansible-tower-service {start|stop|restart|status}

[root@node01-ansible ~]# whereis ansible-tower-service
ansible-tower-service: /usr/bin/ansible-tower-service

We can see the status as below.

root@node01-ansible ~]# ansible-tower-service status
Showing Tower Status
Redirecting to /bin/systemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-02-19 14:41:57 +08; 31min ago
 Main PID: 17462 (beam.smp)
   Status: "Initialized"
    Tasks: 85
   Memory: 9.9M
.
.
.
<removed>
Redirecting to /bin/systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-02-19 14:48:19 +08; 25min ago
  Process: 29497 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 29495 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 29492 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 29500 (nginx)
    Tasks: 3
   Memory: 3.3M
 .
.
.
<removed>
Redirecting to /bin/systemctl status supervisord.service
● supervisord.service - Process Monitoring and Control Daemon
   Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-02-19 14:48:18 +08; 25min ago
  Process: 29373 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS)
 Main PID: 29376 (supervisord)
    Tasks: 31
   Memory: 1.2G
   CGroup: /system.slice/supervisord.service
           ├─29376 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
           ├─29524 python3 /usr/bin/failure-event-handler
           ├─29525 python3 /usr/bin/awx-manage run_dispatcher
           ├─29526 scl enable rh-postgresql10 /var/lib/awx/venv/awx/bin/uwsgi -s /var/run/tower/u...
           ├─29527 python3 /usr/bin/awx-manage runworker --only-channels websocket.*
           ├─29528 python3 /var/lib/awx/venv/awx/bin/daphne -u /var/run/tower/daphne.sock awx.asg...
           ├─29530 python3 /usr/bin/awx-manage run_callback_receiver
           ├─29544 /bin/bash /var/tmp/sclH4YNbr
           ├─29553 /var/lib/awx/venv/awx/bin/uwsgi -s /var/run/tower/uwsgi.sock --module=awx.wsgi...
           ├─29554 /var/lib/awx/venv/awx/bin/uwsgi -s /var/run/tower/uwsgi.sock --module=awx.wsgi...
           ├─29555 /var/lib/awx/venv/awx/bin/uwsgi -s /var/run/tower/uwsgi.sock --module=awx.wsgi...
           ├─29556 /var/lib/awx/venv/awx/bin/uwsgi -s /var/run/tower/uwsgi.sock --module=awx.wsgi...
.
.
.
<removed>

Stop or Start Ansible Tower

Stopping, Starting or Restarting Ansible Tower using ansible-tower-service is simple and straightforward.

# ansible-tower-service stop
Stopping Tower
Redirecting to /bin/systemctl stop rabbitmq-server.service
Redirecting to /bin/systemctl stop nginx.service
Redirecting to /bin/systemctl stop supervisord.service

Once we done our patching or activity, start the service,

# ansible-tower-service start
Starting Tower
Redirecting to /bin/systemctl start rabbitmq-server.service
Redirecting to /bin/systemctl start nginx.service
Redirecting to /bin/systemctl start supervisord.service

You can also achieve the same result via standard init or distribution based service management commands but above one is an easy to use utility for Ansible Tower.

Exit mobile version