Basics In Ansible

========================================================
[root@bserver ~]# rpm -qa httpd

[root@aserver ~]# ansible bserver.example.org -m yum -a “name=httpd state=present”bserver.example.org | SUCCESS => {
“changed”: true,
“msg”: “”,
“rc”: 0,
“results”: [
“Loaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: mirror.dhakacom.com\n * extras: mirror.dhakacom.com\n * updates: mirror.dhakacom.com\nResolving Dependencies\n–> Running transaction check\n—> Package httpd.x86_64 0:2.4.6-45.el7.centos will be installed\n–> Processing Dependency: httpd-tools = 2.4.6-45.el7.centos for package: httpd-2.4.6-45.el7.centos.x86_64\n–> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-45.el7.centos.x86_64\n–> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-45.el7.centos.x86_64\n–> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-45.el7.centos.x86_64\n–> Running transaction check\n—> Package apr.x86_64 0:1.4.8-3.el7 will be installed\n—> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed\n—> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos will be installed\n—> Package mailcap.noarch 0:2.1.41-2.el7 will be installed\n–> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n httpd x86_64 2.4.6-45.el7.centos base 2.7 M\nInstalling for dependencies:\n apr x86_64 1.4.8-3.el7 base 103 k\n apr-util x86_64 1.5.2-6.el7 base 92 k\n httpd-tools x86_64 2.4.6-45.el7.centos base 84 k\n mailcap noarch 2.1.41-2.el7 base 31 k\n\nTransaction Summary\n================================================================================\nInstall 1 Package (+4 Dependent packages)\n\nTotal download size: 3.0 M\nInstalled size: 10 M\nDownloading packages:\n——————————————————————————–\nTotal 187 kB/s | 3.0 MB 00:16 \nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n Installing : apr-1.4.8-3.el7.x86_64 1/5 \n Installing : apr-util-1.5.2-6.el7.x86_64 2/5 \n Installing : httpd-tools-2.4.6-45.el7.centos.x86_64 3/5 \n Installing : mailcap-2.1.41-2.el7.noarch 4/5 \n Installing : httpd-2.4.6-45.el7.centos.x86_64 5/5 \n Verifying : httpd-tools-2.4.6-45.el7.centos.x86_64 1/5 \n Verifying : mailcap-2.1.41-2.el7.noarch 2/5 \n Verifying : apr-1.4.8-3.el7.x86_64 3/5 \n Verifying : httpd-2.4.6-45.el7.centos.x86_64 4/5 \n Verifying : apr-util-1.5.2-6.el7.x86_64 5/5 \n\nInstalled:\n httpd.x86_64 0:2.4.6-45.el7.centos \n\nDependency Installed:\n apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 \n httpd-tools.x86_64 0:2.4.6-45.el7.centos mailcap.noarch 0:2.1.41-2.el7 \n\nComplete!\n”
]
}

[root@bserver ~]# rpm -qa httpd
httpd-2.4.6-45.el7.centos.x86_64
========================================================
[root@bserver ~]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)

[root@aserver ~]# ansible bserver.example.org -m yum -a “name=httpd state=present”
bserver.example.org | SUCCESS => {
“changed”: false,
“msg”: “”,
“rc”: 0,
“results”: [
“httpd-2.4.6-45.el7.centos.x86_64 providing httpd is already installed”
]
}
========================================================
[root@aserver ~]# ansible bserver.example.org -m service -a “name=httpd state=started”
bserver.example.org | SUCCESS => {
“changed”: true,
“name”: “httpd”,
“state”: “started”,
“status”: {
“ActiveEnterTimestampMonotonic”: “0”,
“ActiveExitTimestampMonotonic”: “0”,
“ActiveState”: “inactive”,
“After”: “basic.target remote-fs.target network.target systemd-journald.socket system.slice nss-lookup.target -.mount”,
“AllowIsolate”: “no”,
“AssertResult”: “no”,
“AssertTimestampMonotonic”: “0”,
“Before”: “shutdown.target”,
“BlockIOAccounting”: “no”,
“BlockIOWeight”: “18446744073709551615”,
“CPUAccounting”: “no”,
“CPUQuotaPerSecUSec”: “infinity”,
“CPUSchedulingPolicy”: “0”,
“CPUSchedulingPriority”: “0”,
“CPUSchedulingResetOnFork”: “no”,
“CPUShares”: “18446744073709551615”,
“CanIsolate”: “no”,
“CanReload”: “yes”,
“CanStart”: “yes”,
“CanStop”: “yes”,
“CapabilityBoundingSet”: “18446744073709551615”,
“ConditionResult”: “no”,
“ConditionTimestampMonotonic”: “0”,
“Conflicts”: “shutdown.target”,
“ControlPID”: “0”,
“DefaultDependencies”: “yes”,
“Delegate”: “no”,
“Description”: “The Apache HTTP Server”,
“DevicePolicy”: “auto”,
“Documentation”: “man:httpd(8) man:apachectl(8)”,
“EnvironmentFile”: “/etc/sysconfig/httpd (ignore_errors=no)”,
“ExecMainCode”: “0”,
“ExecMainExitTimestampMonotonic”: “0”,
“ExecMainPID”: “0”,
“ExecMainStartTimestampMonotonic”: “0”,
“ExecMainStatus”: “0”,
“ExecReload”: “{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -k graceful ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }”,
“ExecStart”: “{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -DFOREGROUND ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }”,
“ExecStop”: “{ path=/bin/kill ; argv[]=/bin/kill -WINCH ${MAINPID} ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }”,
“FailureAction”: “none”,
“FileDescriptorStoreMax”: “0”,
“FragmentPath”: “/usr/lib/systemd/system/httpd.service”,
“GuessMainPID”: “yes”,
“IOScheduling”: “0”,
“Id”: “httpd.service”,
“IgnoreOnIsolate”: “no”,
“IgnoreOnSnapshot”: “no”,
“IgnoreSIGPIPE”: “yes”,
“InactiveEnterTimestampMonotonic”: “0”,
“InactiveExitTimestampMonotonic”: “0”,
“JobTimeoutAction”: “none”,
“JobTimeoutUSec”: “0”,
“KillMode”: “control-group”,
“KillSignal”: “18”,
“LimitAS”: “18446744073709551615”,
“LimitCORE”: “18446744073709551615”,
“LimitCPU”: “18446744073709551615”,
“LimitDATA”: “18446744073709551615”,
“LimitFSIZE”: “18446744073709551615”,
“LimitLOCKS”: “18446744073709551615”,
“LimitMEMLOCK”: “65536”,
“LimitMSGQUEUE”: “819200”,
“LimitNICE”: “0”,
“LimitNOFILE”: “4096”,
“LimitNPROC”: “2783”,
“LimitRSS”: “18446744073709551615”,
“LimitRTPRIO”: “0”,
“LimitRTTIME”: “18446744073709551615”,
“LimitSIGPENDING”: “2783”,
“LimitSTACK”: “18446744073709551615”,
“LoadState”: “loaded”,
“MainPID”: “0”,
“MemoryAccounting”: “no”,
“MemoryCurrent”: “18446744073709551615”,
“MemoryLimit”: “18446744073709551615”,
“MountFlags”: “0”,
“Names”: “httpd.service”,
“NeedDaemonReload”: “no”,
“Nice”: “0”,
“NoNewPrivileges”: “no”,
“NonBlocking”: “no”,
“NotifyAccess”: “main”,
“OOMScoreAdjust”: “0”,
“OnFailureJobMode”: “replace”,
“PermissionsStartOnly”: “no”,
“PrivateDevices”: “no”,
“PrivateNetwork”: “no”,
“PrivateTmp”: “yes”,
“ProtectHome”: “no”,
“ProtectSystem”: “no”,
“RefuseManualStart”: “no”,
“RefuseManualStop”: “no”,
“RemainAfterExit”: “no”,
“Requires”: “-.mount basic.target”,
“RequiresMountsFor”: “/tmp /var/tmp”,
“Restart”: “no”,
“RestartUSec”: “100ms”,
“Result”: “success”,
“RootDirectoryStartOnly”: “no”,
“RuntimeDirectoryMode”: “0755”,
“SameProcessGroup”: “no”,
“SecureBits”: “0”,
“SendSIGHUP”: “no”,
“SendSIGKILL”: “yes”,
“Slice”: “system.slice”,
“StandardError”: “inherit”,
“StandardInput”: “null”,
“StandardOutput”: “journal”,
“StartLimitAction”: “none”,
“StartLimitBurst”: “5”,
“StartLimitInterval”: “10000000”,
“StartupBlockIOWeight”: “18446744073709551615”,
“StartupCPUShares”: “18446744073709551615”,
“StatusErrno”: “0”,
“StopWhenUnneeded”: “no”,
“SubState”: “dead”,
“SyslogLevelPrefix”: “yes”,
“SyslogPriority”: “30”,
“SystemCallErrorNumber”: “0”,
“TTYReset”: “no”,
“TTYVHangup”: “no”,
“TTYVTDisallocate”: “no”,
“TimeoutStartUSec”: “1min 30s”,
“TimeoutStopUSec”: “1min 30s”,
“TimerSlackNSec”: “50000”,
“Transient”: “no”,
“Type”: “notify”,
“UMask”: “0022”,
“UnitFilePreset”: “disabled”,
“UnitFileState”: “disabled”,
“Wants”: “system.slice”,
“WatchdogTimestampMonotonic”: “0”,
“WatchdogUSec”: “0”
}
}

[root@bserver ~]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2016-12-31 08:21:54 EST; 80ms ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 12314 (httpd)
Status: “Processing requests…”
CGroup: /system.slice/httpd.service
├─12314 /usr/sbin/httpd -DFOREGROUND
├─12315 /usr/sbin/httpd -DFOREGROUND
├─12316 /usr/sbin/httpd -DFOREGROUND
├─12317 /usr/sbin/httpd -DFOREGROUND
├─12318 /usr/sbin/httpd -DFOREGROUND
└─12319 /usr/sbin/httpd -DFOREGROUND

Dec 31 08:21:14 bserver.example.org systemd[1]: Starting The Apache H…
Dec 31 08:21:34 bserver.example.org httpd[12314]: AH00557: httpd: apr…
Dec 31 08:21:34 bserver.example.org httpd[12314]: AH00558: httpd: Cou…
Dec 31 08:21:54 bserver.example.org systemd[1]: Started The Apache HT…
Hint: Some lines were ellipsized, use -l to show in full.

========================================================
[root@aserver ~]# ansible bserver.example.org -m service -a “name=httpd enabled=yes”
bserver.example.org | SUCCESS => {
“changed”: true,
“enabled”: true,
“name”: “httpd”,
“status”: {
“ActiveEnterTimestamp”: “Sat 2016-12-31 08:21:54 EST”,
“ActiveEnterTimestampMonotonic”: “6727201763”,
“ActiveExitTimestampMonotonic”: “0”,
“ActiveState”: “active”,
“After”: “-.mount remote-fs.target network.target nss-lookup.target system.slice systemd-journald.socket basic.target”,
“AllowIsolate”: “no”,
“AssertResult”: “yes”,
“AssertTimestamp”: “Sat 2016-12-31 08:21:14 EST”,
“AssertTimestampMonotonic”: “6687055802”,
“Before”: “shutdown.target”,
“BlockIOAccounting”: “no”,
“BlockIOWeight”: “18446744073709551615”,
“CPUAccounting”: “no”,
“CPUQuotaPerSecUSec”: “infinity”,
“CPUSchedulingPolicy”: “0”,
“CPUSchedulingPriority”: “0”,
“CPUSchedulingResetOnFork”: “no”,
“CPUShares”: “18446744073709551615”,
“CanIsolate”: “no”,
“CanReload”: “yes”,
“CanStart”: “yes”,
“CanStop”: “yes”,
“CapabilityBoundingSet”: “18446744073709551615”,
“ConditionResult”: “yes”,
“ConditionTimestamp”: “Sat 2016-12-31 08:21:14 EST”,
“ConditionTimestampMonotonic”: “6687055801”,
“Conflicts”: “shutdown.target”,
“ControlGroup”: “/system.slice/httpd.service”,
“ControlPID”: “0”,
“DefaultDependencies”: “yes”,
“Delegate”: “no”,
“Description”: “The Apache HTTP Server”,
“DevicePolicy”: “auto”,
“Documentation”: “man:httpd(8) man:apachectl(8)”,
“EnvironmentFile”: “/etc/sysconfig/httpd (ignore_errors=no)”,
“ExecMainCode”: “0”,
“ExecMainExitTimestampMonotonic”: “0”,
“ExecMainPID”: “12314”,
“ExecMainStartTimestamp”: “Sat 2016-12-31 08:21:14 EST”,
“ExecMainStartTimestampMonotonic”: “6687059497”,
“ExecMainStatus”: “0”,
“ExecReload”: “{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -k graceful ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }”,
“ExecStart”: “{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -DFOREGROUND ; ignore_errors=no ; start_time=[Sat 2016-12-31 08:21:14 EST] ; stop_time=[n/a] ; pid=12314 ; code=(null) ; status=0/0 }”,
“ExecStop”: “{ path=/bin/kill ; argv[]=/bin/kill -WINCH ${MAINPID} ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }”,
“FailureAction”: “none”,
“FileDescriptorStoreMax”: “0”,
“FragmentPath”: “/usr/lib/systemd/system/httpd.service”,
“GuessMainPID”: “yes”,
“IOScheduling”: “0”,
“Id”: “httpd.service”,
“IgnoreOnIsolate”: “no”,
“IgnoreOnSnapshot”: “no”,
“IgnoreSIGPIPE”: “yes”,
“InactiveEnterTimestampMonotonic”: “0”,
“InactiveExitTimestamp”: “Sat 2016-12-31 08:21:14 EST”,
“InactiveExitTimestampMonotonic”: “6687059821”,
“JobTimeoutAction”: “none”,
“JobTimeoutUSec”: “0”,
“KillMode”: “control-group”,
“KillSignal”: “18”,
“LimitAS”: “18446744073709551615”,
“LimitCORE”: “18446744073709551615”,
“LimitCPU”: “18446744073709551615”,
“LimitDATA”: “18446744073709551615”,
“LimitFSIZE”: “18446744073709551615”,
“LimitLOCKS”: “18446744073709551615”,
“LimitMEMLOCK”: “65536”,
“LimitMSGQUEUE”: “819200”,
“LimitNICE”: “0”,
“LimitNOFILE”: “4096”,
“LimitNPROC”: “2783”,
“LimitRSS”: “18446744073709551615”,
“LimitRTPRIO”: “0”,
“LimitRTTIME”: “18446744073709551615”,
“LimitSIGPENDING”: “2783”,
“LimitSTACK”: “18446744073709551615”,
“LoadState”: “loaded”,
“MainPID”: “12314”,
“MemoryAccounting”: “no”,
“MemoryCurrent”: “18446744073709551615”,
“MemoryLimit”: “18446744073709551615”,
“MountFlags”: “0”,
“Names”: “httpd.service”,
“NeedDaemonReload”: “no”,
“Nice”: “0”,
“NoNewPrivileges”: “no”,
“NonBlocking”: “no”,
“NotifyAccess”: “main”,
“OOMScoreAdjust”: “0”,
“OnFailureJobMode”: “replace”,
“PermissionsStartOnly”: “no”,
“PrivateDevices”: “no”,
“PrivateNetwork”: “no”,
“PrivateTmp”: “yes”,
“ProtectHome”: “no”,
“ProtectSystem”: “no”,
“RefuseManualStart”: “no”,
“RefuseManualStop”: “no”,
“RemainAfterExit”: “no”,
“Requires”: “-.mount basic.target”,
“RequiresMountsFor”: “/tmp /var/tmp”,
“Restart”: “no”,
“RestartUSec”: “100ms”,
“Result”: “success”,
“RootDirectoryStartOnly”: “no”,
“RuntimeDirectoryMode”: “0755”,
“SameProcessGroup”: “no”,
“SecureBits”: “0”,
“SendSIGHUP”: “no”,
“SendSIGKILL”: “yes”,
“Slice”: “system.slice”,
“StandardError”: “inherit”,
“StandardInput”: “null”,
“StandardOutput”: “journal”,
“StartLimitAction”: “none”,
“StartLimitBurst”: “5”,
“StartLimitInterval”: “10000000”,
“StartupBlockIOWeight”: “18446744073709551615”,
“StartupCPUShares”: “18446744073709551615”,
“StatusErrno”: “0”,
“StatusText”: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec”,
“StopWhenUnneeded”: “no”,
“SubState”: “running”,
“SyslogLevelPrefix”: “yes”,
“SyslogPriority”: “30”,
“SystemCallErrorNumber”: “0”,
“TTYReset”: “no”,
“TTYVHangup”: “no”,
“TTYVTDisallocate”: “no”,
“TimeoutStartUSec”: “1min 30s”,
“TimeoutStopUSec”: “1min 30s”,
“TimerSlackNSec”: “50000”,
“Transient”: “no”,
“Type”: “notify”,
“UMask”: “0022”,
“UnitFilePreset”: “disabled”,
“UnitFileState”: “disabled”,
“Wants”: “system.slice”,
“WatchdogTimestamp”: “Sat 2016-12-31 08:21:54 EST”,
“WatchdogTimestampMonotonic”: “6727201542”,
“WatchdogUSec”: “0”
}
}

[root@bserver ~]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2016-12-31 08:21:54 EST; 2min 9s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 12314 (httpd)
Status: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec”
CGroup: /system.slice/httpd.service
├─12314 /usr/sbin/httpd -DFOREGROUND
├─12315 /usr/sbin/httpd -DFOREGROUND
├─12316 /usr/sbin/httpd -DFOREGROUND
├─12317 /usr/sbin/httpd -DFOREGROUND
├─12318 /usr/sbin/httpd -DFOREGROUND
└─12319 /usr/sbin/httpd -DFOREGROUND

Dec 31 08:21:14 bserver.example.org systemd[1]: Starting The Apache HTTP Server…
Dec 31 08:21:34 bserver.example.org httpd[12314]: AH00557: httpd: apr_sockaddr_info_get() failed for bserver.example.org
Dec 31 08:21:34 bserver.example.org httpd[12314]: AH00558: httpd: Could not reliably determine the server’s fully qualified domain nam…message
Dec 31 08:21:54 bserver.example.org systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
========================================================

[root@aserver ~]# ansible bserver.example.org -m user -a “user=jack”
bserver.example.org | SUCCESS => {
“changed”: true,
“comment”: “”,
“createhome”: true,
“group”: 1001,
“home”: “/home/jack”,
“name”: “jack”,
“shell”: “/bin/bash”,
“state”: “present”,
“system”: false,
“uid”: 1001
}
[root@bserver ~]# grep jack /etc/passwd
jack:x:1001:1001::/home/jack:/bin/bash

========================================================

Variable-Precedence

1)Extra vars
2)Task vars(only for the task)
3)Block vars(only for tasks in the block)
4)Role &include facts
5)Play vars-file
6)Play vars-prompt
7)Play vars
8)Set-facts
9)Registered vars
10)Host facts
11)Palybook host-vars
12)Playbook group-vars
13)Inventory host-vars
14)Inventory group-vars
15)Inventory vars
16)Role defaults

===================================================================
[root@bserver ~]# rpm -qa epel-release
===================================================================
[root@aserver ~]# vim first.yaml

– name: install and start apache
hosts: bserver.example.org

tasks:
– name: install epel repo
yum: name=epel-release state=present
===================================================================
[root@aserver ~]# ansible-playbook first.yaml

PLAY [install and start apache] ************************************************

TASK [setup] *******************************************************************
ok: [bserver.example.org]

TASK [install epel repo] *******************************************************
changed: [bserver.example.org]

PLAY RECAP *********************************************************************
bserver.example.org : ok=2 changed=1 unreachable=0 failed=0
===================================================================

[root@bserver ~]# rpm -qa epel-release
epel-release-7-6.noarch
===================================================================

[root@bserver ~]# rpm -qa nginx

[root@bserver ~]# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1324/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1662/master
tcp6 0 0 :::22 :::* LISTEN 1324/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1662/master

====================================================================
[root@aserver ~]# vim second.yaml
– name: playbook for nginx
hosts: bserver.example.org

tasks:
– name: install epel repo
yum: name=epel-release state=present

– name: installing nginx
yum: name=nginx state=present

– name: start nginx service
service: name=nginx state=started enabled=yes

====================================================================

[root@aserver ~]# ansible-playbook second.yaml

PLAY [playbook for nginx] ******************************************************

TASK [setup] *******************************************************************
ok: [bserver.example.org]

TASK [install epel repo] *******************************************************
ok: [bserver.example.org]

TASK [installing nginx] ********************************************************
changed: [bserver.example.org]

TASK [start nginx service] *****************************************************
changed: [bserver.example.org]

PLAY RECAP *********************************************************************
bserver.example.org : ok=4 changed=2 unreachable=0 failed=0

====================================================================
[root@bserver ~]# rpm -qa nginx
nginx-1.10.2-1.el7.x86_64
[root@bserver ~]# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14001/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1324/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1662/master
tcp6 0 0 :::80 :::* LISTEN 14001/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1324/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1662/master
====================================================================

[root@aserver ~]# cat >>testing
hai this for testing copy
[root@aserver ~]# ansible bserver.example.org -m copy -a “src=testing dest=/root/one”
bserver.example.org | SUCCESS => {
“changed”: true,
“checksum”: “7c172c7468a383b864eaa9c1d5dab85b672bbcc8”,
“dest”: “/root/one”,
“gid”: 0,
“group”: “root”,
“md5sum”: “36b28a2d0de68cdb9da751f07d2fc0fb”,
“mode”: “0644”,
“owner”: “root”,
“secontext”: “system_u:object_r:admin_home_t:s0”,
“size”: 79,
“src”: “/root/.ansible/tmp/ansible-tmp-1483218889.05-57627058747676/source”,
“state”: “file”,
“uid”: 0
}

[root@bserver ~]# cat one
hai this for testing copy

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s