-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_b_module_example.txt
70 lines (62 loc) · 1.89 KB
/
6_b_module_example.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
refer- https://docs.ansible.com/ansible/2.5/modules/command_module.html#command-module
create directory by using command/shell module:
-----------------------------------------
- name: automation
hosts: all
become: true
tasks:
- name: execute directory
command: mkdir /home/newDir
refer: https://docs.ansible.com/ansible/latest/collections/community/general/apache2_module_module.html
--------------------------------------------------------------------------------
install webserver by using httpd module
---------------------------------------
- name: installing apache by usign httpd
hosts: all
become: true
tasks:
- name: (httpd module)
yum:
name: httpd
state: present
- name: (service module)
service:
name: httpd
state: present
copy shell script from master to node by usign script module
------------------------------------------------------------
- name: copy code from master to node
hosts: all
become: root
tasks:
- name: copy
script: /file/path/script.sh
[example-2]
------------
- name: playbok for automate script
hosts: all
become: root
tasks:
- name: copy from master to node
script: /etc/ansible/script.sh
[shell script]
--------------
#!/bin/bash
sudo yum install httpd -y
sudo systemctl start httpd.service
sudo wget -P /var/www/html https://www.free-css.com/assets/files/free-css-templates/download/page284/pet-shop.zip
sudo unzip -o /var/www/html/pet-shop.zip -d /var/www/html/
sudo cp -rf /var/www/html/pet-shop-website-template/* /var/www/html/
wget -P for purticulr directory
unzip -o from overwrite
unzip -d for save in purticular directory
lineinfile module add a line in file
------------------------------------
- name: installing apache by usign httpd
hosts: all
become: true
tasks:
- name: add line in resolv file
lineinfile:
path: /etc/resolv.conf
line: nameserver 192.168.1.1