Changes

Jump to: navigation, search

OPS435 Online Lab9

722 bytes added, 00:22, 26 March 2021
Part 2: Sample runs for some of the Ad hoc commands
== Part 2: Sample runs for some of the Ad hoc commands ==
The following commands are based on the following entries in the ansible inventory file called "hosts" in the current working directory:
<pre>
...[ops435b]jkwok ansible_host=myvmlab.senecacollege.ca ansible_port=7850cdee ansible_host=myvmlab.senecacollege.ca ansible_port=7874...</pre><pre>[rchanraymond.chan@centos7 ansiblemtrx-node02pd lab9]$ ansible 192.168.99.153 jkwok -i hosts --private-key id_rsa -u instructor -m copy -a "src=/home/rchanraymond.chan/ops435/ansiblelab9/ansible.txt hosts dest=/tmp/ansible.txtansible_hosts"192.168.99.153 jkwok | SUCCESS CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" },
"changed": true,
"checksum": "837affc90674fb92cdb0ebac6e49ad31a586b37ebc4ffa4127e3af3228e61f0ddc4fca87c5e548a4", "dest": "/tmp/ansible.txtansible_hosts", "gid": 10011003, "group": "rchaninstructor", "md5sum": "78ae49d77d28d06173cf2194a390973217e94f6ee9ce0920ebf835bd4f6250a7",
"mode": "0664",
"owner": "rchan", "secontext": "unconfined_u:object_r:user_home_t:s0instructor", "size": 106423, "src": "/home/rchaninstructor/.ansible/tmp/ansible-tmp-15429021191616732233.1549-236519-11761853951330935150082693243/source",
"state": "file",
"uid": 10011003
}
 
</pre>
: 192jkwok is the remote machine ID.168: hosts is the name of the ansible inventory file in the current working directory, you may also specify the inventory file with full path name, e.99g.153 /home/raymond.chan/ops435/lab9/hosts. : --private-key id_ras is the private key for ssh key-based authentication for connecting to the remote machine.: -u is for specifying the user account to be used to login to the remote machine's IP address.: "-m copy" tells is to tell ansible to use the "copy " module.
: after '-a' is the arguments to the copy module, which specify the source file and the destination for the copy action.
: If you got the same "SUCCESS" message, login to the remote machine (in this example, it is 192.168.99.153) and check the directory "/tmp" for the file ansible.txtansible_hosts.
== Part 3: Sample runs for using some Ansible's built-in modules ==
1,760
edits

Navigation menu