1.yaml中有很多参数时,建议使用折叠符(>):
E.g:
- name: Configure nginx command: > ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-stream --with-http_stub_status_module args: chdir: "/tmp/nginx-{{ nginx_version }}" creates: "/tmp/nginx-{{ nginx_version }}/Makefile"2.yaml中有多个命令要顺序执行时,建议使用多行文本符号(|),将多行内容作为一个完整字符串传递给shell模块执行
E.g:
- name: Install nginx shell: | cd /tmp tar -xzf nginx-1.28.0.tar.gz cd nginx-1.28.0 ./configure --prefix=/usr/local/nginx make make install实际含义:
cd /tmp tar -xzf nginx-1.28.0.tar.gz cd nginx-1.28.0 ./configure --prefix=/usr/local/nginx make make install总结:
| = 保留换行(Literal) > = 换行变空格(Folded)