teenpolt.blogg.se

Ansible untar example
Ansible untar example





ansible untar example

The device can be either external media or a local file. Throughout this chapter the command structures use "device" to specify both a target location for backup, and the source location when restoring. NoSleep.sh - A simple Configuration Script Verifying DISA STIG Compliance with OpenSCAP - Part 2 Host-based Intrusion Detection System (HIDS)Ĭompression compress, gzip, bzip2, lzip and xzĪdd a file or directory to an existing backupĮxtract a group of files from a tar backup using regular expressions (regex)īash - Conditional structures if and case

#Ansible untar example update#

We could also update the permissions and ownership for the copied files using “copy” module.Building and Installing Custom Linux KernelsĪutomatic Template Creation - Packer - Ansible - VMware vSphere ::1 localhost localhost.localdomain localhost6 ~]$ 1 root root 158 Jul 11 06:16 1 root root 557 Jul 11 06:16 ~]$ cat localhost localhost.localdomain localhost4 localhost4.localdomain4 ~]$ ansible uaans69 -b -m copy -a 'src=/etc/hosts dest=/etc/hosts backup=yes' Is it possible to take a backup before overwriting it? Offcourse, You can do that using “backup” keyword. We must take the backup of any configuration file before editing it. "secontext": "system_u:object_r:net_conf_t:s0", ~]$ ansible uaans69 -b -m copy -a 'src=/etc/hosts dest=/etc/hosts' “/etc/hosts” modification requires root privileges. ~]$ ansible uaans69 -m copy -a 'src=/etc/hosts dest=/etc/hosts' The following copy action failed since we didn’t escalate the privileges. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 cat /etc/hostsġ27.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 Here are the uaans69’s “/etc/hosts” contents. Copy the Ansible server’s /etc/hosts file to remote host “uaans69”. Use the fetch module to copy files from remote locations to the local host.ġ. The copy module copies a file from the local or remote machine to a location on the remote machine. ” copy ” Module- Copies files to remote locations: You could change the permission and ownership of the directory file module. Last login: Wed Jul 11 06:03:13 2018 from ~]$ ls -ld /var/tmp/archiveĭrwxrwxr-x. ~]$ ansible uaans69 -m file -a 'path=/var/tmp/archive state=directory' Create a new directory on the host and verify. ~]$ ansible uaans69 -m file -a 'src=/etc/hosts dest=/var/tmp/hosts state=link' Ls: cannot access /var/tmp/ansible_test.txt: No such file or ~]$Ĥ. Last login: Wed Jul 11 05:09:49 2018 from ~]$ ls -lrt /var/tmp/ansible_test.txt ~]$ ansible uaans69 -m file -a 'path=/var/tmp/ansible_test.txt state=absent' Remove the newly created file and verify by directly logging in to the host. "uid": ~]$ ssh uaans69 ls -lrt /var/tmp/ansible_test.txt ~]$ ansible uaans69 -b -m file -a 'path=/var/tmp/ansible_test.txt owner=root group=root mode=0644' Let’s change the file permission and ownership and verify by directly logging in to the host. 1 sysadmin sysadmin 0 Jul 11 05:09 ~]$ logout

ansible untar example ansible untar example

Last login: Wed Jul 11 05:09:24 2018 from ~]$ ls -lrt /var/tmp/ansible_test.txt Verify our work by logging in to uaans69 host. "secontext": "unconfined_u:object_r:user_tmp_t:s0", ~]$ ansible uaans69 -m file -a 'path=/var/tmp/ansible_test.txt state=touch' Create a blank file on the host (uaans69) with a given path using ansible. Login to Ansible server and list the hosts. Let’s demonstrate the functions of “file” and “copy” modules.ġ. You could quickly push the configuration to multiple hosts using these modules. These modules are very often used in Ad-hoc mode to push the application configurations, system configurations etc. “Copy” module is used to copy the files to hosts from Ansible server. File module is used for setting file attributes like permission, ownership and creating the links. Ansible “Ad-hoc” mode can be used to copy/delete/modify files on the specific host or Group of hosts using ansible modules.







Ansible untar example