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
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
要在Ubuntu安装Ansible,您可以按照以下步骤操作: 1. 首先,您需要更新apt软件包索引并安装软件属性常规工具: ``` sudo apt update sudo apt install software-properties-common ``` 2. 添加Ansible存储库:[3] ``` sudo add-apt-repository --yes --update ppa:ansible/ansible ``` 3. 安装Ansible: ``` sudo apt install ansible ``` 4. 安装完成后,您可以使用以下命令来验证Ansible是否正确安装: ``` ansible --version ``` 请注意,这些步骤假设您已经在全新的Ubuntu安装上执行。如果您已经安装了Python和pip,您可以直接使用pip安装Ansible: ``` sudo apt-get install python-pip sudo pip install ansible ``` 此外,如果您需要使用Gnome Shell设置Ubuntu,请运行存储库中的`setup_gnome.yml`剧本: ``` ansible-playbook setup_gnome.yml ``` 更详细的安装指南可以在Ansible的官方文档网站上找到:<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Ubuntu部署ansible(详细教程)](https://blog.csdn.net/Johnyangyuan/article/details/119916108)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [ubuntu-ansible:从头开始安装Ubuntu计算机](https://download.csdn.net/download/weixin_42153793/18320719)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值