简体   繁体   English

在 EC2 实例上从 Ubuntu(windows ubuntu 终端)运行 Ansible Playbook

[英]Running Ansible Playbook from Ubuntu (windows ubuntu terminal) on EC2 Instance

I am trying to run my ansible playbook through ubuntu Terminal in Windows on a EC2 Instance我正在尝试通过 EC2 实例上的 Windows 中的 ubuntu 终端运行我的 ansible playbook

I can log in with following ssh example to the EC2 Instance我可以使用以下 ssh 示例登录到 EC2 实例

ssh -i /path/to/my/pemfile.pem ubuntu@ipadress-of-my-EC2

with that command I successfully login to my EC2 Instance.使用该命令我成功登录到我的 EC2 实例。

Now I want to run Ansible with following inventory file现在我想使用以下清单文件运行 Ansible

[ec2_test]
hostnameofec2 ansible_host='ipadress-of-ec2' ansible_ssh_user='ubuntu' ansible_ssh_private_key_file='/path/to/my/pemfile.pem'

When I run this in my command line当我在命令行中运行它时

ansible-playbook /path/to/my/inventory test.yml -vvvv

I get the following output in the console:我在控制台中得到以下输出:

ansible-playbook 2.9.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/mladen/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/mladen/.local/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15+ (default, Oct  7 2019, 17:39:04) [GCC 7.4.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

ERROR! Syntax Error while loading YAML.
  did not find expected <document start>

The error appears to be in '/mnt/d/GGstudio/Ansible/inventory/ggstudio/inventory': line 2, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

[ec2_test]
hostnameofec2 ansible_host='ipadress-of-ec2' ansible_ssh_user='ubuntu' ansible_ssh_private_key_file='/path/to/my/pemfile.pem'
^ here

So I don't understand how the provided host list is empty when I assign the host in the inventory file?所以当我在清单文件中分配主机时,我不明白提供的主机列表如何为空?

Thank you in advance.先感谢您。

问题已解决,忘记了 -i 参数...抱歉发垃圾邮件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM