准备
在开始学习ansible module 之前我们先来做一下准备工作,打开vscode创建一个新的项目module for file & copy。
目录
- ansible-module
- inventory
- files
- test.txt
- group_vars
- pangshare.yml
- ansible.cfg
- hosts
- playbook.yml
- files
- inventory
内容
# pangshare.yml ansible_connection: ssh ansible_ssh_user: root
# ansible.cfg [defaults] inventory= hosts private_key_file= /root/.ssh/ansible
# hosts [pangshare] ansible-node1 ansible-node2
# playbook.yml
- name: ansible Module for file & copy
hosts: pangshare
tasks:
- name: ansible Module for file
file:
path: /etc/ansible-Module-test
state: directory
- name: ansible Module for copu
copy:
src: files/test.txt
dest: /etc/ansible-Module-test/test.txt
结果

参考
此文章为原创文章,作者:胖哥叨逼叨,如若转载,请与我联系并注明出处:https://www.pangshare.com/2432.htm
微信扫一扫