-
Overview
At this post we will reveal below ansible modules and get them on practice with examplescommand copy file user group service script setup ping
-
Ansible module - command
Example: Run command to get ip address from remote server
Execute below command from shell-master node, ansible will post the command to specified inventory node for execution:ansible webservers -m command -a "ip addr"
-
Ansible module - copy
[root@shell-master ~]# ansible-doc -s copy - name: Copy files to remote locations
Example: Copy local file to remote target server
First we create 1 simple file on shell-master
Then using Ansible copy module copy it to remote server[root@shell-master ~]# ansible webservers -m copy -a "src=copy-to-remote.txt dest=/tmp/ mode=755 owner=wayne"
Once the command finished, login back to shell-node1 check if the file been copied to required location as required:
-
Ansible module - file
[root@shell-master ~]# ansible-doc -s file - name: Manage files and file properties
Example: Let's update the file attribute we just copied to remote server from step 3
Run below command, to change the file's owner from wayne to root, change the access mode from 755 to 777[root@shell-master ~]# ansible webservers -m file -a "path=/tmp/copy-to-remote.txt owner=root mode=777"
After the command done for running, go back to shell-node1, verify if the file properties been updated:
相关文章
- 12-10Ansible基础认识及安装使用详解(week5_day1_part1)--技术流ken
- 12-10Level3_Unit1_Part3#Listening·Buying a New Car1
- 12-101. 10min语法速学; 2. 常用命令; 3. Go Modules & goproxy.cn; 4. 进阶; 5. 标准库; 6. 第三方库
- 12-10DevExpress WPF让创建绑定到数据的3D图表控件变得更容易(Part 1)
- 12-10Level 4 Unit 3 part 1
- 12-10How to implement a YOLO (v3) object detector from scratch in PyTorch: Part 1翻译与总结
- 12-10An Introduction to Interactive Programming in Python (Part 1) -- Week 2_3 练习
- 12-102 - Ansible common modules Part 2
- 12-10(三)CDA 数据分析师Level1考试新版大纲解析(自己整理)PART 3 数据库应用PART 3 数据库应用 (占比 17%)
- 12-103 - Ansible common modules Part 1