一、playbook基本格式如下

[root@linux-node1 ansible]# cat file.yaml 
---
  # 主机
- hosts: date
  # 用户
  remote_user: root
  
  # 任务
  tasks:
    - name: create new_file
      file: name=/data/newfile state=touch
    - name: create new_user
      user: name=test2 system=yes shell=/sbin/nologin
    - name: install package
      yum: name=httpd
    - name: copy html
      copy: src=/data/html.html dest=/data/html.html
    - name: start service
      service: name=httpd state=started enabled=yes

检查语法

ansible-playbook -C file.yaml

没有问题执行

ansible-playbook  file.yaml

ansible-playbook基础使用(二)

 二、ansible-playbook 、ansible通用命令

[root@linux-node1 ansible]# ansible-playbook file.yaml --list-host

playbook: file.yaml

  play #1 (date): date	TAGS: []
    pattern: [u'date']
    hosts (3):
      192.168.56.11
      192.168.56.12
      192.168.56.13
[root@linux-node1 ansible]# ansible-playbook file.yaml --list-tag

playbook: file.yaml

  play #1 (date): date	TAGS: []
      TASK TAGS: []

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2021-09-16
  • 2021-06-27
  • 2021-09-15
  • 2022-02-08
猜你喜欢
  • 2021-06-30
  • 2021-10-31
  • 2021-10-11
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案