美文网首页
Linux虚拟机上离线安装ansible awx_亲测成功

Linux虚拟机上离线安装ansible awx_亲测成功

作者: beyond阿亮 | 来源:发表于2022-03-09 21:11 被阅读0次

Linux虚拟机上离线安装ansible awx_亲测成功

可自行去下载相关包,也可以给我评论留言,我发给大家

ansible awx离线安装----虚拟机上安装 成功-----------------------------
python -V
2.7.5

tar -zxvf setuptools-20.0.tar.gz
cd setuptools-20.0
python setup.py install

tar -zxvf pycrypto-2.6.1.tar.gz 
cd pycrypto-2.6.1/
python setup.py install

报错时:  error: no acceptable C compiler found in $PATH
有网机器下载
yum install --downloadonly --downloaddir=/data/ansible/gcc gcc
yum install --downloadonly --downloaddir=/data/ansible/g++ gcc-c++

cd gcc/
rpm -ivh *.rpm

cd g++
rpm -ivh *.rpm

报错时 src/MD2.c:31:20: 致命错误:Python.h:没有那个文件或目录
yum install python-devel -y
Tips :若python版本已经为2.6或以上,则不需要再重装python,只是还需要安装python开发包:python-dev(有的操作系统下为python-devel)

yum install --downloadonly --downloaddir=/data/ansible/python-devel python-devel
cd python-devel/
rpm -ivh *.rpm

然后再执行
cd pycrypto-2.6.1/
python setup.py install

tar -zxvf yaml-0.1.5.tar.gz 
cd yaml-0.1.5/
./configure --prefix=/usr/local
make --jobs=`grep processor /proc/cpuinfo | wc -l`
make install

https://pypi.org/simple/pyyaml/
tar -zxvf PyYAML-3.11.tar.gz
cd PyYAML-3.11/
python setup.py install

tar -zxvf MarkupSafe-0.9.3.tar.gz 
cd MarkupSafe-0.9.3/
python setup.py install

tar -zxvf Jinja2-2.7.3.tar.gz 
cd Jinja2-2.7.3/
python setup.py install

tar -zxvf ecdsa-0.11.tar.gz 
cd ecdsa-0.11/
python setup.py install

tar -zxvf paramiko-1.15.1.tar.gz 
cd paramiko-1.15.1/
python setup.py install

tar -zxvf simplejson-3.6.5.tar.gz 
cd simplejson-3.6.5/
python setup.py install

tar -zxvf pycparser-2.20.tar.gz
cd pycparser-2.20
python setup.py install

tar -zxvf ipaddress-1.0.23.tar.gz 
cd ipaddress-1.0.23
python setup.py install

tar -zxvf enum34-1.1.10.tar.gz 
cd enum34-1.1.10
python setup.py install

tar -zxvf six-1.15.0.tar.gz
cd six-1.15.0
python setup.py install

https://pypi.python.org/simple/cryptography/
tar -zxvf cryptography-2.9.2.tar.gz 
cd cryptography-2.9.2
python setup.py install

报错时: c/_cffi_backend.c:15:17: 致命错误:ffi.h:没有那个文件或目录
yum install --downloadonly --downloaddir=/data/ansible/libffi-devel libffi-devel
cd libffi-devel/
rpm -ivh *.rpm

yum install --downloadonly --downloaddir=/data/ansible/openssl-devel openssl-devel
cd openssl-devel
rpm -ivh *.rpm

tar -zxvf cffi-1.14.0.tar.gz 
cd cffi-1.14.0
python setup.py install

https://releases.ansible.com/ansible/
wget https://releases.ansible.com/ansible/ansible-2.9.7.tar.gz
tar -zxvf ansible-2.9.7.tar.gz
cd ansible-2.9.7/
python setup.py install

ansible --version

pip -V

tar -zxvf pip-20.1.1.tar.gz 
cd pip-20.1.1
python setup.py install
pip -V

pip download docker -d /data/ansible/docker
pip install --ignore-installed requests --no-index --find-links=file:/data/ansible/docker docker
 
pip download docker-compose -d /data/ansible/docker_compose 
pip install --no-index --find-links=file:/data/ansible/docker_compose docker_compose

netstat -tpnl
查看端口占用: 80

tar -zxvf awx-13.0.0.tar.gz 需要python3 没成功
cd awx-11.0.0/installer/ 
vi inventory 可以修改用户名密码
admin_user=admin
admin_password=password
ansible-playbook -i inventory install.yml

tar -zxvf 11.0.0.tar.gz  成功安装
cd awx-11.0.0/installer/ 
ansible-playbook -i inventory install.yml

浏览器访问: http://192.168.31.105/
报错: A server error has occurred.

vim inventory 修改
postgres_data_dir="/data/ansible/pgdocker"
#host_port_ssl=443
docker_compose_dir="/data/ansible/awxcompose"

导入清单
docker exec -it awx_task /bin/bash
cat /data/hosts 
[docker-host]
192.168.31.236 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=root

新建一个docker 清单名
awx-manage inventory_import --source=/data/hosts --group-filter=docker-host --inventory-name=docker --keep-vars

把容器删除后再试
docker stop awx_task awx_web awx_postgres awx_redis awx_memcached
docker rm awx_task awx_web awx_postgres awx_redis awx_memcached

想法:
安装好的awx,配置好所有软件脚本,然后把容器导出来,到其他机器运行时,各种错误,只有awx_postgres能跑起来.

换种方式: 把镜像和共享卷导出到其他机器上运行,指定好共享卷路径启动 docker-compose.yml 成功了


容器迁移 当前容器保存成镜像
docker commit -p awx_postgres awx_postgres-new 保存成镜像
docker save -o /data/awx_postgres-new.tar awx_postgres-new:latest 导出镜像
docker load -i awx_postgres-new.tar 导入镜像

docker save -o /data/awx_memcached.tar memcached:alpine
docker save -o /data/awx_redis.tar redis:latest
docker save -o /data/awx_postgres.tar postgres:10
docker save -o /data/awx_web.tar ansible/awx_web:11.0.0
docker save -o /data/awx_task.tar ansible/awx_task:11.0.0


docker run --name awx_redis --privileged=true -d \
-p 6379:6379 \
-v /data/ansible/redis/redis.conf:/usr/local/etc/redis/redis.conf \
-v /data/ansible/redis/redis_socket_standalone:/var/run/redis/ \
awx_redis-new

redis.conf 空文件
注释 redis.sock
#unixsocket /var/run/redis/redis.sock
#unixsocketperm 770
redis_socket_standalone 空文件夹
Redis能成功启动了

docker run --privileged=true --name awx_memcached -d \
-v /data/ansible/memcached/:/var/run/memcached \
awx_memcached-new
memcached启动失败

awx_postgres 启动成功

docker run --name awx_web --privileged=true -d \
-p 80:80 \
awx_web-new
Web 失败 要nginx配置
docker run --name awx_task --privileged=true -d \
awx_task-new
task失败 etc/tower/SECRET_KEY

tar -zcvf ansible.tar.gz ansible 打包
cd /data/ansible
tar -zcvf awxcompose.tar.gz awxcompose
tar -zcvf pgdocker.tar.gz pgdocker

把共享卷awxcompose和pgdocker复制到/data/ansible目录

使用docker-compose启动 成功
docker-compose up -d
docker-compose stop
docker-compose rm

getenforce  查询SELinux的运行模式
使用命令setenforce 0 临时设置系统参数
修改/etc/selinux/config文件中设置SELINUX=disabled ,重启服务器

cat docker-compose.yml  成功了
version: '2'
services:

  web:
    image: ansible/awx_web:11.0.0
    container_name: awx_web
    depends_on:
      - redis
      - memcached
      - postgres
    ports:
      - "80:8052"
    hostname: awxweb
    user: root
    restart: unless-stopped
    volumes:
      - supervisor-socket:/var/run/supervisor
      - rsyslog-socket:/var/run/awx-rsyslog/
      - rsyslog-config:/var/lib/awx/rsyslog/
      - "/data/ansible/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY"
      - "/data/ansible/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh"
      - "/data/ansible/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py"
      - "/data/ansible/awxcompose/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "/data/ansible/awxcompose/redis_socket:/var/run/redis/:rw"
      - "/data/ansible/awxcompose/memcached_socket:/var/run/memcached/:rw"
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  task:
    image: ansible/awx_task:11.0.0
    container_name: awx_task
    depends_on:
      - redis
      - memcached
      - web
      - postgres
    hostname: awx
    user: root
    restart: unless-stopped
    volumes:
      - supervisor-socket:/var/run/supervisor
      - rsyslog-socket:/var/run/awx-rsyslog/
      - rsyslog-config:/var/lib/awx/rsyslog/
      - "/data/ansible/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY"
      - "/data/ansible/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh"
      - "/data/ansible/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py"
      - "/data/ansible/awxcompose/redis_socket:/var/run/redis/:rw"
      - "/data/ansible/awxcompose/memcached_socket:/var/run/memcached/:rw"
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''
      SUPERVISOR_WEB_CONFIG_PATH: '/supervisor.conf'

  redis:
    image: redis:latest
    container_name: awx_redis
    restart: unless-stopped
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''
    command: ["/usr/local/etc/redis/redis.conf"]
    volumes:
      - "/data/ansible/awxcompose/redis.conf:/usr/local/etc/redis/redis.conf:ro"
      - "/data/ansible/awxcompose/redis_socket:/var/run/redis/:rw"
      - "/data/ansible/awxcompose/memcached_socket:/var/run/memcached/:rw"

  memcached:
    image: memcached:alpine
    container_name: awx_memcached
    command: ["-s", "/var/run/memcached/memcached.sock", "-a", "0666"]
    restart: unless-stopped
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''
    volumes:
      - "/data/ansible/awxcompose/memcached_socket:/var/run/memcached/:rw"

  postgres:
    image: postgres:10
    container_name: awx_postgres
    restart: unless-stopped
    volumes:
      - /data/ansible/pgdocker/10/data/:/var/lib/postgresql/data/pgdata:Z
    environment:
      POSTGRES_USER: awx
      POSTGRES_PASSWORD: awxpass
      POSTGRES_DB: awx
      PGDATA: /var/lib/postgresql/data/pgdata
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''
volumes:
  supervisor-socket:
  rsyslog-socket:
  rsyslog-config:


相关文章

网友评论

      本文标题:Linux虚拟机上离线安装ansible awx_亲测成功

      本文链接:https://www.haomeiwen.com/subject/byrxdrtx.html