ansible playbook 循环 loop

重复执行某条命令


- hosts: ncbi
tasks:

- name: see
shell: touch /home/zcy/cc/'sdfa_'{{ item }}
loop: "{{ range(20,29) | list }}"

 

在使用 Ansible Playbook 执行需要 sudo 权限的命令时,可以通过以下方法解决密码输入问题:
# inventory.ini
[webservers]
192.168.1.100 ansible_user=ubuntu ansible_become_pass=your_password
192.168.1.101 ansible_user=ubuntu ansible_become_pass=your_password

[all:vars]
ansible_become=yes
ansible_become_method=sudo

 

posted on 2025-07-22 14:01  我和你并没有不同  阅读(7)  评论(0)    收藏  举报