ubuntu安装ansible并且安装awx管理

一、 更新系统

  1. sudo apt update && sudo apt -y upgrade

  2. sudo reboot

二、安装ansible

  1. sudo apt install ansible

  2. ansible --version

  3. 修改ansible主机的主机清单,加入你要执行的节点地址。

    vim /etc/ansible/hosts

    [web]

    192.168.37.140

    192.168.37.141

  4. 测试结果 ansible all -m ping 192.168.37.140 | SUCCESS => { "changed": false, "ping": "pong" } 192.168.37.141 | SUCCESS => { "changed": false, "ping": "pong" }

  5. 免密ssh-key(可选)

    ssh-keygen

    ssh-copy-id ip地址

    去掉yes/no的询问

    1. vim /etc/ssh/ssh_confih

      StrictHostKeyChecking no

    2. systemctl restart sshd

  6. 安装docker

    1. 安装依赖

      sudo apt-get update
      sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
    2. 安装GPG证书

      curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

    3. 写入安装源

    4. sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

    5. 更新并安装doxker-ce

      sudo apt-get -y update sudo apt-get -y install docker-ce

  7. 下载安装docker-compose

    sudo curl -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-Linux-x86_64 -o /usr/local/bin/docker-compose

    chmod +x /usr/local/bin/docker-compose

    docker-compose version

  8. 安装Nodejs和NPM

    sudo apt install -y nodejs npm sudo npm install npm --global

  9. 安装docker相关python库

    sudo apt install python3-pip pwgen sudo pip3 install requests==2.14.2

  10. 下载并上传ansible awx

    https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2Fansible%2Fawx%2Farchive%2F3.0.0.tar.gz

  11. 解压进入awx目录

    cd awx/installer/

    pwgen -N 1 -s 30(复制生成的key)

  12. 编辑当前目录的inventory文件如下

    localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python3"

    [all:vars] dockerhub_base=ansible awx_task_hostname=awx awx_web_hostname=awxweb postgres_data_dir=/tmp/pgdocker host_port=80 host_port_ssl=443 docker_compose_dir=/tmp/awxcompose pg_username=awx pg_password=awxpass pg_database=awx pg_port=5432 rabbitmq_password=awxpass rabbitmq_erlang_cookie=cookiemonster admin_user=admin admin_password=StrongAdminpassword create_preload_data=True secret_key=(这里为上方key) project_data_dir=/tmp/project

  13. 执行安装

    apt install python-docker

    sudo ansible-playbook -i inventory install.yml

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值