【问题标题】:How to setup ansible for ec2 instance?如何为 ec2 实例设置 ansible?
【发布时间】:2017-08-02 21:50:06
【问题描述】:

我已经启动了一个带有 ubuntu 系统的 ec2 实例。我将通过 ansible 在该系统上安装git。以下是我的剧本文件:

---

- hosts: ec2
  roles:
    - git

下面是我的 git 角色任务文件:

---
- name: install git
  sudo: yes
  yum:
    pkg: git
    state: latest

当我运行 ansible-playbook -i hosts git.yml 时出现以下错误:

TASK [git : install git] *********************************************************************************************************************************************************************************
fatal: [xxxxx.ap-southeast-2.compute.amazonaws.com]: FAILED! => {"changed": false, "failed": true, "msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed fo
r this  module"}
        to retry, use: --limit @/Users/joey/dev/dbkoda/jenkins-docker-file/playbooks/git.retry

我不确定为什么会收到此错误消息。我已经在 ec2 实例上安装了 python。 python2 在 PATH 上可用。

下面是我正在使用的 Ansible 版本:

$ ansible-playbook --version
ansible-playbook 2.3.1.0
  config file =
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Jul 18 2017, 09:17:00) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]

【问题讨论】:

    标签: ansible


    【解决方案1】:

    Yum 是 Red Hat 系列发行版上的标准包管理器。

    Ubuntu,基于 Debian,使用APT

    在 Ansible 中使用 apt module

    您也可以尝试package module,但由于包名称因包管理器而异,因此您可能无法为不同的发行版创建通用播放。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-26
      • 2011-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      • 2021-08-04
      • 1970-01-01
      相关资源
      最近更新 更多