Ansible-Tower--安装配置及破解

摘要:
Ansible-Tower是将ansible的指令界面化,简明直观,简单易用。2)Ansibke-tower其实就是一个图形化的任务调度,复杂服务部署,IT自动化的一个管理平台,属于发布配置管理系统,支持Api及界面操作,Django编写。3)Ansible-tower可以通过界面从github拉取最新playbook实施服务部署,提高生产效率。

一、ansible-tower简介

1)公司中实现运维自动化的架构中主要用到ansible,ansible脚本在部署服务器指令行中显得不太直观。Ansible-Tower(之前叫做awx)是将ansible的指令界面化,简明直观,简单易用。

2)Ansibke-tower其实就是一个图形化的任务调度,复杂服务部署,IT自动化的一个管理平台,属于发布配置管理系统,支持Api及界面操作,Django编写。

3)Ansible-tower可以通过界面从github拉取最新playbook实施服务部署,提高生产效率。当然它也提供一个RESET API和命令行的CLI以供python脚本调用

官方网站:https://www.ansible.com/products/tower
中文指南:http://www.ansible.com.cn/docs/tower.html
官方安装文档:http://docs.ansible.com/ansible-tower/latest/html/quickinstall/index.html
官方源地址:http://releases.ansible.com/ansible-tower/setup-bundle/

二、ansible-tower安装及配置

root@ansible ~]# mv ansible-tower-setup-bundle-3.7.1-1/ /usr/local/ansible-tower
[root@ansible ~]# cd /usr/local/ansible-tower
[root@ansible ansible-tower]# ll
总用量 56
-rw-r--r--.  1 root root   612 6月  17 18:50 backup.yml
drwxr-xr-x.  4 root root    28 6月  17 18:52 bundle
drwxr-xr-x.  2 root root    17 6月  17 18:50 group_vars
-rw-r--r--.  1 root root  6873 6月  17 18:50 install.yml
-rw-r--r--.  1 root root   856 6月  17 18:50 inventory
drwxr-xr-x.  3 root root  8192 6月  17 18:50 licenses
-rw-r--r--.  1 root root  2506 6月  17 18:50 README.md
-rw-r--r--.  1 root root  1335 6月  17 18:50 rekey.yml
-rw-r--r--.  1 root root  1518 6月  17 18:50 restore.yml
drwxr-xr-x. 21 root root  4096 6月  17 18:50 roles
-rwxr-xr-x.  1 root root 10888 6月  17 18:50 setup.sh
[root@ansible ansible-tower]# vim inventory
[root@ansible ansible-tower]# ./setup.sh

image-20200729135055264

需要认证:

image

三、ansible-tower破解

[root@ansible ansible-tower]# cd /var/lib/awx/venv/awx/lib/python3.6/site-packages/tower_license
[root@ansible tower_license]# ll
总用量 12
-rw-r--r--. 1 root root 8348 6月  17 17:00 __init__.pyc
drwxr-xr-x. 2 root root   37 7月  29 01:13 __pycache__
[root@ansible tower_license]# wget https://bootstrap.pypa.io/get-pip.py
--2020-07-29 01:28:24--  https://bootstrap.pypa.io/get-pip.py
正在解析主机 bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.228.175, 2a04:4e42:1a::175
正在连接 bootstrap.pypa.io (bootstrap.pypa.io)|151.101.228.175|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1869136 (1.8M) [text/x-python]
正在保存至: “get-pip.py”

get-pip.py                           100%[=====================================================================>]   1.78M  15.1KB/s  用时 96s

2020-07-29 01:30:01 (19.1 KB/s) - 已保存 “get-pip.py” [1869136/1869136])

[root@ansible tower_license]# python get-pip.py
-bash: python: 未找到命令
[root@ansible tower_license]# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>
[1]+  已停止               python3
[root@ansible tower_license]# python3 get-pip.py
Collecting pip
  Downloading pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 20 kB/s
Collecting wheel
  Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Installing collected packages: pip, wheel
  Attempting uninstall: pip
    Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
Successfully installed pip-20.1.1 wheel-0.34.2
[root@ansible tower_license]# pip -V
pip 20.1.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
[root@ansible tower_license]#  pip install uncompyle6
Collecting uncompyle6
  Downloading uncompyle6-3.7.3-py3-none-any.whl (315 kB)
     |████████████████████████████████| 315 kB 17 kB/s
Collecting xdis<5.1.0,>=4.7.0
  Downloading xdis-5.0.2-py36-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 7.1 kB/s
Collecting spark-parser<1.9.0,>=1.8.9
  Downloading spark_parser-1.8.9-py3-none-any.whl (17 kB)
Collecting click
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 12 kB/s
Installing collected packages: xdis, click, spark-parser, uncompyle6
Successfully installed click-7.1.2 spark-parser-1.8.9 uncompyle6-3.7.3 xdis-5.0.2
[root@ansible tower_license]#  uncompyle6 __init__.pyc >__init__.py
[root@ansible tower_license]# ll
总用量 1852
-rw-r--r--. 1 root root 1869136 5月  19 18:45 get-pip.py
-rw-r--r--. 1 root root   12145 7月  29 01:34 __init__.py
-rw-r--r--. 1 root root    8348 6月  17 17:00 __init__.pyc
drwxr-xr-x. 2 root root      37 7月  29 01:13 __pycache__
[root@ansible tower_license]# vim __init__.py
[root@ansible tower_license]# python3 -m py_compile __init__.py
Sorry: IndentationError: unindent does not match any outer indentation level (__init__.py, line 89)
[root@ansible tower_license]# vim __init__.py
[root@ansible tower_license]# python3 -m py_compile __init__.py
[root@ansible tower_license]# python3 -O -m py_compile __init__.py
[root@ansible tower_license]# ansible-tower-service restart
[root@ansible tower_license]#

修改如下:

image-20200729140141494

#访问https://192.168.1.116/#/license

image-20200729140255487

四、运行测试项目

playbook将在github上创建,Ansible Tower拉取执行,Ansible Tower的playbook默认存在 /var/lib/awx/projects/

1)创建host登录凭据

[image

image-20200729140503839

image-20200729140535697

2)在gitlab中添加playbook项目

image-20200729140607352

3)在Ansible Tower添加拉取github项目的凭据

image-20200729140709052

4)创建project

image-20200729140751133

保存后Ansilble Tower会自动运行一次Update,如果要手动运行,点击列表中的刷新按钮。当gitlab上yml文件被更新或者新增后需要点击一下刷新按钮,否则JOB执行得还是原来的yml

image-20200729140917270

image-20200729141009889

此时在Ansible Tower服务器的/var/lib/awx/projects/目录下已经有git拉下来的完整文件结构

image-20200729141056513

5)创建主机清单

image-20200729141457834

image-20200729141528951

6)创建任务模板

image-20200729141656898

7)运行模板

image

image-20200729141734566

点击右侧日志中change几行可以看到详细信息

image-20200729141807351

五、安装tomcat8测试

1)编写playbook

image-20200729141840640

---
- hosts: all
  remote_user: root
  tasks:
    - name: "copy files to remote host"
      copy:
        src={{ item.src }}
        dest={{ item.dest }}
      with_items:
        - src: /usr/local/src/apache-tomcat-8.5.47.tar.gz
          dest: /usr/local/
    - name: "install tomcat8"
      shell: cd /usr/local/ && tar xf apache-tomcat-8.5.47.tar.gz
    - name: "rename file"
      shell: mv /usr/local/apache-tomcat-8.5.47 /usr/local/tomcat8
    - name: "start tomcat"
      shell: 'nohup /usr/local/tomcat8/bin/startup.sh &'

注意:我已经提前安装了openjdk

[root@ansible src]# java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)

2)创建inventory

image-20200729142451378

image-20200729142515452

3)创建project

image-20200729142617449

4)创建模板

image-20200729142648338

5)运行模板

image-20200729142714190

6)浏览器测试tomcat

http://192.168.1.116:8080/

image-20200729142336168

参考文档:https://www.cnblogs.com/hujinzhong/p/12172903.html

免责声明:文章转载自《Ansible-Tower--安装配置及破解》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇centos登录密码正确但一直报login incorrect错误(错误赋予权限)SkyWalking 服务端配置下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

python3 爬去QQ音乐

1 import requests 2 import re 3 import json 4 import os 5 6 7 8 def get_name(singer): 9 url = 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp' 10...

centos Linux 统计某个文件夹占用空间大小

转载自http://www.07net01.com/linux/centos_Linux_tongjimougewenjianjiazhanyongkongjiandaxiao_12510_1346373058.html 1、查看当前文件夹下面各个文件的大小 ll -lh 2、查看某文件夹占用总的空间大小 du -h --max-depth=1 /usr/...

ansible-基础命令

命令格式 absible <主机或者分组列表> [选项] //ansible all 就是全部主机 -M 指定模块路径 -m 使用模块,默认是command模块 -a或者--args 模块参数 -i是inventory文件路径或者可执行脚本 -k 使用交互式登陆密码 -e 定义变量 -v详细信息,-vvvv开启debug模式 ansible...

Linux 和Windows之间命令行实现目录或文件互传

Linux 和Windows之间命令行实现目录或文件互传 在linux中,我们常用scp命令传输文件: 如以下实例,我们想把当前服务器文件abc.sql传输到192.168.1.1服务器上 我们可以执行以下命令: scp /home/person/hww/abc.sql root@192.168.1.1:/home/person/hww  回车后输入...

三星Galaxy S8 刷机经验记录

这段时间用上了三星S8,由于原生系统太耗电,所以萌生了root的想法。写这篇博客记录下这段时间的各种尝试。 Root过程说明: 友情提示,道路千万条,安全第一条。开始捣鼓手机之前请一定准备好官方的救砖包。 1.解锁手机,我手上这台S8,时需要手机端先下载软件(crom1.0.8.apk)进行解锁; 2.刷入第三方recovery,我选择的TWRP,在TWR...

解决 ‘Could not fetch URL https://pypi.python.org’的问题

【前提】: win10下python3和python2共存环境,但是环境变量只配置了python3 【问题】: 用pip安装一个包执行pip2 install xxx的时候报错Fatal error in launcher: Unable to create process using '"' 执行pip3 install xxx的时候报同样的错误Fata...