-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-shell.yml
37 lines (33 loc) · 1.11 KB
/
3-shell.yml
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
---
#This is comment.
#https://docs.ansible.com/ansible/latest/modules/shell_module.html
- hosts: test-server
remote_user: root
tasks:
- name: "1.Executing Shell commands for simple Print"
shell: echo "Hello Ansible `hostname`" >> /root/tmp
args:
executable: /bin/bash
- name: "2.Changing and printing my working Directory"
shell: pwd && date >> log.out
args:
chdir: /var/log/path/mypath
creates: mylog.txt
executable: /bin/bash
- name: "3.Running script and Redirecting standard output."
shell: cat file 1> output.out 2> error.out
#shell: cat /var/log/path/mypath/file 1> output.out 2> error.out
args:
chdir: /var/log/path/mypath
executable: /bin/bash
- name: "4.Executing my shell script at remote_host"
shell: /usr/bin/myscript.sh 2> /tmp/error.out 1> /tmp/log.out
args:
executable: /bin/bash
- name: "5.Curl to url using socks proxy"
shell: curl --socks5 localhost:9000 http://www.ansible.com 2> curl-error.out 1> curl-out.out
args:
#msg: False
warn: no
executable: /bin/bash
chdir: /var/log/path/mypath