我要执行以下操作:
---
- name: install stuff
hosts: h1
tasks:
- name: install stuffs
tags: install_stuffs
apt:
name: "{{ packages }}"
update_cache: yes
shell: | # multiline string, right?
apt-key bla_bla
apt:
name: other_package
vars:
packages:
- python3
- nano
但是,Ansible报告apt
是重复的。这是为什么? YAML是否将我的task
(命名为install stuff
)字典用作字典?以及如何实现我想要的功能:apt
然后运行一些命令,然后运行apt
?谢谢!
答案 0 :(得分:2)
YAML是否将我的任务(命名为安装资料)当作字典?
是
以及如何实现我想要的:apt然后运行一些命令然后apt?
您需要将这些步骤分解为单独的任务:
---
- name: install stuff
hosts: h1
tasks:
- name: install stuffs
tags: install_stuffs
apt:
name: "{{ packages }}"
update_cache: yes
vars:
packages:
- python3
- nano
- name: run stuff
shell: apt-key bla_bla
- name: install more stuff
apt:
name: other_package