一、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