본문 바로가기

Automation Tools/Ansible

1.6 ansible | [test][playbook] multi command

반응형

[root@OPENLDAP-TEST ansible]# cat multi_command.yml
---
- name: "command test"
  hosts: all
  become: true
  tasks:
    - name: "iptables insert"
      command: "{{ item }}"
      with_items:
        - iptables -D INPUT -s 2.2.2.2
        - iptables -D INPUT -s 3.3.3.3
        - iptables -D INPUT -s 4.4.4.4
        - iptables -D INPUT -s 1.1.1.1 -j ACCEPT
 
## command, shell 모두 유효
## with_items 로 여러 명령을 내릴수 있음.
반응형