我是靠谱客的博主 粗暴跳跳糖,这篇文章主要介绍ansible-playbook 配合yml文件,实现批量功能,现在分享给大家,希望可以做个参考。

一、copy功能

yml文件:

---

- name: configure copy local file to remote_host

  hosts: all

  tasks:

  - name: copy yum config file

    copy:

    src: files/centos7.repo

    dest: /etc/yum.repos.d/

执行文件    ansible-playbook copy.yml

二、安装软件,启动软件,我们已安装httpd,php,php-mysql为例

yml文件:

---

- name: configure web server

  hosts: webserver

  tasks:

  - name: install web app

    yum:

      name: "{{item}}"

      state: present

    with_items:

       - httpd

       - php

       - php-mysql

  - name: configure web app

    service:

      name: httpd

      state: started

      enabled: true

执行命令   ansibl-playbook lamp.yml

最后

以上就是粗暴跳跳糖最近收集整理的关于ansible-playbook 配合yml文件,实现批量功能的全部内容,更多相关ansible-playbook内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(103)

评论列表共有 0 条评论

立即
投稿
返回
顶部