ansible-playbook基础使用(二)
一、playbook基本格式如下
[ 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通用命令
[ 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 [ ansible]# ansible-playbook file.yaml --list-tag playbook: file.yaml play #1 (date): date TAGS: [] TASK TAGS: []
相关推荐
laisean 2020-09-27
onepiecedn 2020-10-29
guchengxinfen 2020-10-12
houdaiye 2020-09-23
逆时针 2020-08-19
pzczyy 2020-08-19
annan 2020-08-02
hpujsj 2020-07-26
annan 2020-07-18
逆时针 2020-06-21
annan 2020-06-20
逆时针 2020-06-14
逆时针 2020-06-14
awoyaoc 2020-06-12
逆时针 2020-06-09
piaotiejun 2020-06-07
awoyaoc 2020-06-07