Ansible语法问题运行shell命令和docker_container模块

时间:2017-03-21 15:11:47

标签: ansible

我所拥有的是有效的YAML但由于某种原因它对Ansible无效,Ansible网站上的文档有一些运行模块的很好的例子,但是没有关于模块如何的任何文档共同努力或如果可以的话。我假设我可以在同一个任务中运行一个shell模块和一个docker_container模块,但在我看来,似乎Ansible不同意我的看法。这就是我所拥有的。

---
- name: Setup Rancher Container
   shell: sudo su_root
   docker_container:
     name: rancherserver
     image: rancher/server
     state: started
     restart_policy: always
     published_ports: 8080:8080

...

ERROR! conflicting action statements

The error appears to have been in '/opt/ansible_scripts/ansible/roles/dockermonitoring
/tasks/main.yml': line 2, column 3, but maybe elsewhere in the file depending on the exact 
syntax problem.

The offending line appears to be:

---
- name: Setup Rancher Container
^ here

因为我在RHEL 7上运行这个,所以我需要能够运行sudo su_root脚本成为root,然后当docker以root身份运行时,ansible可以与Docker API通信。

因此,如果我无法运行此脚本然后运行docker_container,我认为这是ansible的一个大问题。

1 个答案:

答案 0 :(得分:0)

  

我假设我可以在同一个任务中运行shell模块和docker_container模块

错误。一项任务 - 一个模块。

获得特权访问的become参数,例如:

- name: Setup Rancher Container
  become: yes
  docker_container:
    name: rancherserver
    ... 
相关问题