如何使用分隔符在变量中提供多个值-Ansible Playbook

时间:2019-02-27 05:18:40

标签: ansible ansible-template

 - name: Application deployment
    hosts: "{{ target_hosts }}"
    gather_facts: no
    become: yes
    become_method: su
    become_user: 'root'
    roles:
    - APP_deployment 
    vars:
      - password_supersu: 'Abcdefg@Linux'
      - ansible_su_pass: 'Abcdefg@Linux' 

    vars_prompt:
    - name: "target_hosts"
      prompt: "Please input the Target Host name:"
      default: ""
      private: no
    - name: "war_name"
      prompt: "Please input the War files name:"
      default: ""
      private: no
    - name: "chksum_src"
      prompt: "Please input the MD5chksum value :"
      default: ""

   tasks: 
   - add_hosts:
         name: ""{{target_hosts}}""
         groups: dynamically_created_hosts

   - with_iteams: 
         ""{{ war_name. split (',') }}""
         ""{{ chksum_src. split (',') }}""

使用此剧本,我可以将多个主机作为目标,使用分隔符,但是如果我想对战名和Md5chksum值也使用相同的主机。

简单地说,我想通过chksum值检查将多个文件部署到多个主机,该任务已经在角色中定义,但是也可以将chksum值和文件名分开。

预先感谢

0 个答案:

没有答案