标题:[实践OK] Ansible建立批量偶数目录~ 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Thu, 12 Apr 2018 15:46:59 +0000 作者:jackxiang 地址:https://jackxiang.com/post/9713/ 内容: cat t3.yml --- - hosts: localhost tasks: # create a series of directories with even numbers for some reason - file: dest=/tmp/test/{{ item }} state=directory with_sequence: start=4 end=16 stride=2 ls /tmp/test/ 10 12 14 16 4 6 8 来自:http://54im.com/ansible-doc/playbooks_loops.html#looping-over-integer-sequences 批量创建目录: - name: 创建目录 file: path={{ item }} state=directory recurse=no owner=www mode=0755 with_items: - '/data/www/data/weixin' - '/data/www/cache/weixin' - '/data/www/applogs/weixin' Generated by Jackxiang's Bo-blog 2.1.1 Release