关于ansible:Linux虚拟机上离线安装ansible-awx亲测成功

41次阅读

共计 7221 个字符,预计需要花费 19 分钟才能阅读完成。

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:

正文完
 0