playbook 之tasks

- hosts: all
  tasks:
  - name: ping test
    ping:
  - name: from remote host copy file 
    fetch:
      src: /etc/hosts
      dest: .
      owner: root
      mode: 0600
- hosts: 127.0.0.1
  tasks:
  - name: copy file to remote host
    copy:
      src: /etc/hosts
      dest: /tmp
  - name: mkdir
    file:
      path: /tmp/testdir/1
      state: directory
      recurse: yes
      owner: test
  - name: touch
    file:
      path: /tmp/testdir/1/1.txt
      state: touch
      owner: test
      mode: 0600
  - name: link
    file:
      path: /tmp/testdir/2
      state: link
      src: /tmp/testdir/1/1.txt
      owner: test
      mode: 0600

语法检查 ansible-playbook --syntax-check play.yml
模拟执行 语法检查 ansible-playbook --check play.yml
执行playbook ansible-playbook play.yml

posted @ 2023-01-17 09:03  mingtian是吧  阅读(48)  评论(0编辑  收藏  举报