playbook的复用

 

1)编写安装nginx

[root@m01 ~]# cat nginx.yml 
- name: Install Nginx Server
  yum:
    name: nginx
    state: present

2)编写启动nginx

[root@m01 ~]# cat start.yml 
- name: Start Nginx Server
  systemd:
    name: nginx
    state: started
    enabled: yes

3)编写调用的剧本

[root@m01 ~]# cat main.yml 
- hosts: nfs
  tasks:
    - include_tasks: nginx.yml
    - include_tasks: start.yml

4)直接调用写好的playbook

[root@m01 ~]# cat main.yml 
- import_playbook: lnmp1.yml
- import_playbook: lnmp2.yml

 

posted @ 2020-10-07 15:12  六月OvO  阅读(92)  评论(0编辑  收藏  举报