一、软件环境

  • CentOS 7.9(最小化安装)
  • Ansible 2.9.25
  • Ansible-tower 3.8.3

二、安装

1、离线安装Ansible

先使用一台可以联网的虚拟机,下载所有需要的依赖包

# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# yum install ansible --downloadonly --downloaddir=./

然后,将所有rpm包上传到没有网络的离线服务器(模拟生产环境的内网服务器),然后一条命令即可完成安装操作。

检查ansible的版本信息

# ansible --version
ansible 2.9.25
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

2、安装Ansible-tower

从下面的页面下载3.8.3版本的Ansible-tower

https://releases.ansible.com/ansible-tower/setup-bundle/

上传到服务器,解压,修改安装目录下的inventory文件,设置相关的密码字段。

创建日志目录,这一步不执行,会导致安装过程报错中断

# mkdir -p /var/log/tower

执行./setup.sh即可开始安装。 

【勘误-20211123】

如果虚拟机完全断网,下面的安装会报错中断。经过测试发现,Ansible-tower在安装过程中还需要安装特定的组件(如:rh-postgres10-postgres、rh-redis5等),以及300多个依赖包。

Ansible-tower服务管理的基本命令:

ansible-tower-service start|stop|restart|status

# ansible-tower-service status
● ansible-tower.service - Ansible Tower service
   Loaded: loaded (/usr/lib/systemd/system/ansible-tower.service; enabled; vendor preset: disabled)
   Active: active (exited) since 五 2021-10-22 12:04:30 CST; 40s ago
  Process: 8375 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 8375 (code=exited, status=0/SUCCESS)

10月 22 12:04:30 ansible-tower systemd[1]: Starting Ansible Tower service...
10月 22 12:04:30 ansible-tower systemd[1]: Started Ansible Tower service.

● rh-postgresql10-postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/rh-postgresql10-postgresql.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/rh-postgresql10-postgresql.service.d
           └─override.conf
   Active: active (running) since 五 2021-10-22 11:53:36 CST; 11min ago
 Main PID: 3961 (postmaster)
    Tasks: 16
   Memory: 13.2M
   CGroup: /system.slice/rh-postgresql10-postgresql.service
           ├─3961 /opt/rh/rh-postgresql10/root/usr/bin/postmaster -D /var/opt/rh/rh-postgresql10/lib/pgsql/data
           ├─3963 postgres: logger process   
           ├─3965 postgres: checkpointer process   
           ├─3966 postgres: writer process   
           ├─3967 postgres: wal writer process   
           ├─3968 postgres: autovacuum launcher process   
           ├─3969 postgres: stats collector process   
           ├─3970 postgres: bgworker: logical replication launcher   
           ├─8423 postgres: awx awx 127.0.0.1(56384) idle
           ├─8443 postgres: awx awx 127.0.0.1(56390) idle
           ├─8444 postgres: awx awx 127.0.0.1(56392) idle
           ├─8445 postgres: awx awx 127.0.0.1(56394) idle
           ├─8465 postgres: awx awx 127.0.0.1(56410) idle
           ├─8466 postgres: awx awx 127.0.0.1(56412) idle
           ├─8467 postgres: awx awx 127.0.0.1(56414) idle
           └─8476 postgres: awx awx 127.0.0.1(56422) idle

10月 22 11:53:36 ansible-tower systemd[1]: Stopped PostgreSQL database server.
10月 22 11:53:36 ansible-tower systemd[1]: Starting PostgreSQL database server...
10月 22 11:53:36 ansible-tower postmaster[3961]: < 2021-10-22 03:53:36.683 UTC  >日志:  listening on IPv4 address "0.0.0.0", port 5432
10月 22 11:53:36 ansible-tower postmaster[3961]: < 2021-10-22 03:53:36.683 UTC  >日志:  listening on IPv6 address "::", port 5432
10月 22 11:53:36 ansible-tower postmaster[3961]: < 2021-10-22 03:53:36.685 UTC  >日志:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
10月 22 11:53:36 ansible-tower postmaster[3961]: < 2021-10-22 03:53:36.686 UTC  >日志:  listening on Unix socket "/tmp/.s.PGSQL.5432"
10月 22 11:53:36 ansible-tower postmaster[3961]: < 2021-10-22 03:53:36.704 UTC  >日志:  日志输出重定向到日志收集进程
10月 22 11:53:36 ansible-tower postmaster[3961]: < 2021-10-22 03:53:36.704 UTC  >提示:  后续的日志输出将出现在目录 "pg_log"中.
10月 22 11:53:36 ansible-tower systemd[1]: Started PostgreSQL database server.

● rh-redis5-redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/rh-redis5-redis.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/rh-redis5-redis.service.d
           └─limit.conf, override.conf
   Active: active (running) since 五 2021-10-22 11:59:55 CST; 5min ago
 Main PID: 5771 (redis-server)
    Tasks: 4
   Memory: 4.1M
   CGroup: /system.slice/rh-redis5-redis.service
           └─5771 /opt/rh/rh-redis5/root/usr/bin/redis-server 127.0.0.1:0

10月 22 11:59:55 ansible-tower systemd[1]: Starting Redis persistent key-value database...
10月 22 11:59:55 ansible-tower systemd[1]: Started Redis persistent key-value database.

● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/nginx.service.d
           └─override.conf
   Active: active (running) since 五 2021-10-22 12:04:29 CST; 40s ago
  Process: 8345 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 8342 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 8340 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 8347 (nginx)
    Tasks: 3
   Memory: 2.4M
   CGroup: /system.slice/nginx.service
           ├─8347 nginx: master process /usr/sbin/nginx
           ├─8348 nginx: worker process
           └─8349 nginx: worker process

10月 22 12:04:29 ansible-tower systemd[1]: Stopped The nginx HTTP and reverse proxy server.
10月 22 12:04:29 ansible-tower systemd[1]: Starting The nginx HTTP and reverse proxy server...
10月 22 12:04:29 ansible-tower nginx[8342]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
10月 22 12:04:29 ansible-tower nginx[8342]: nginx: configuration file /etc/nginx/nginx.conf test is successful
10月 22 12:04:29 ansible-tower systemd[1]: Started The nginx HTTP and reverse proxy server.

● supervisord.service - Process Monitoring and Control Daemon
   Loaded: loaded (/usr/lib/systemd/system/supervisord.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/supervisord.service.d
           └─override.conf
   Active: active (running) since 五 2021-10-22 12:04:29 CST; 41s ago
  Process: 8308 ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf (code=exited, status=0/SUCCESS)
 Main PID: 8311 (supervisord)
    Tasks: 32
   Memory: 656.3M
   CGroup: /system.slice/supervisord.service
           ├─8311 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
           ├─8382 python3 /usr/bin/failure-event-handler
           ├─8384 scl enable rh-postgresql10 /var/lib/awx/venv/awx/bin/uwsgi --socket /var/run/tower/uwsgi.sock --module=awx.wsgi:application --stats /var/lib/awx/uwsgi.stats --chmod-socket=660 --vacuum --ma...
           ├─8385 python3 /usr/bin/awx-manage run_wsbroadcast
           ├─8386 python3 /var/lib/awx/venv/awx/bin/daphne -u /var/run/tower/daphne.sock awx.asgi:channel_layer
           ├─8387 python3 /usr/bin/awx-manage run_callback_receiver
           ├─8388 python3 /usr/bin/awx-manage run_dispatcher
           ├─8393 /bin/bash /var/tmp/sclqIhqx8
           ├─8402 /var/lib/awx/venv/awx/bin/uwsgi --socket /var/run/tower/uwsgi.sock --module=awx.wsgi:application --stats /var/lib/awx/uwsgi.stats --chmod-socket=660 --vacuum --master --no-orphans --buffer-...
           ├─8429 /var/lib/awx/venv/awx/bin/uwsgi --socket /var/run/tower/uwsgi.sock --module=awx.wsgi:application --stats /var/lib/awx/uwsgi.stats --chmod-socket=660 --vacuum --master --no-orphans --buffer-...
           ├─8430 /var/lib/awx/venv/awx/bin/uwsgi --socket /var/run/tower/uwsgi.sock --module=awx.wsgi:application --stats /var/lib/awx/uwsgi.stats --chmod-socket=660 --vacuum --master --no-orphans --buffer-...
           ├─8431 /var/lib/awx/venv/awx/bin/uwsgi --socket /var/run/tower/uwsgi.sock --module=awx.wsgi:application --stats /var/lib/awx/uwsgi.stats --chmod-socket=660 --vacuum --master --no-orphans --buffer-...
           ├─8432 /var/lib/awx/venv/awx/bin/uwsgi --socket /var/run/tower/uwsgi.sock --module=awx.wsgi:application --stats /var/lib/awx/uwsgi.stats --chmod-socket=660 --vacuum --master --no-orphans --buffer-...
           ├─8437 python3 /usr/bin/awx-manage run_dispatcher
           ├─8439 python3 /usr/bin/awx-manage run_dispatcher
           ├─8440 python3 /usr/bin/awx-manage run_dispatcher
           ├─8441 python3 /usr/bin/awx-manage run_dispatcher
           ├─8442 python3 /usr/bin/awx-manage run_dispatcher
           ├─8446 python3 /usr/bin/awx-manage run_callback_receiver
           ├─8447 python3 /usr/bin/awx-manage run_callback_receiver
           ├─8448 python3 /usr/bin/awx-manage run_callback_receiver
           ├─8449 python3 /usr/bin/awx-manage run_callback_receiver
           └─8456 rsyslogd -n -i /var/run/awx-rsyslog/rsyslog.pid -f /var/lib/awx/rsyslog/rsyslog.conf

10月 22 12:04:29 ansible-tower systemd[1]: Starting Process Monitoring and Control Daemon...
10月 22 12:04:29 ansible-tower systemd[1]: Started Process Monitoring and Control Daemon.
10月 22 12:04:30 ansible-tower rsyslogd[8383]: [origin software="rsyslogd" swVersion="8.1911.0-8.el7at" x-pid="8383" x-info="https://www.rsyslog.com"] start
10月 22 12:04:35 ansible-tower rsyslogd[8383]: [origin software="rsyslogd" swVersion="8.1911.0-8.el7at" x-pid="8383" x-info="https://www.rsyslog.com"] exiting on signal 15.
10月 22 12:04:35 ansible-tower rsyslogd[8456]: [origin software="rsyslogd" swVersion="8.1911.0-8.el7at" x-pid="8456" x-info="https://www.rsyslog.com"] start

至此,Ansible-tower即安装完成。可以使用https协议,以及服务器的IP地址登录,默认使用443端口。 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐