fetch Fetches a file from remote nodes Author Michael DeHaan Synopsis Options

Fetch fetches a file from remote nodes author michael

This preview shows page 398 - 401 out of 572 pages.

synchronize module, which is a wrapper around rsync. fetch - Fetches a file from remote nodes Author Michael DeHaan • Synopsis • Options • Examples Synopsis This module works like copy , but in reverse. It is used for fetching files from remote machines and storing them locally in a file tree, organized by hostname. Note that this module is written to transfer log files that might not be present, so a missing remote file won’t be an error unless fail_on_missing is set to ‘yes’. 394 Chapter 1. About Ansible
Image of page 398
Ansible Documentation, Release 1.7 Options Examples # Store file into /tmp/fetched/host.example.com/tmp/somefile - fetch: src=/tmp/somefile dest=/tmp/fetched # Specifying a path directly - fetch: src=/tmp/somefile dest=/tmp/prefix-{{ ansible_hostname }} flat=yes # Specifying a destination path - fetch: src=/tmp/uniquefile dest=/tmp/special/ flat=yes # Storing in a path relative to the playbook - fetch: src=/tmp/uniquefile dest=special/prefix-{{ ansible_hostname }} flat=yes file - Sets attributes of files Author Michael DeHaan • Synopsis • Options • Examples Synopsis Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories. Many other modules support the same options as the file module - including copy , template , and assemble . Options Examples - file: path=/etc/foo.conf owner=foo group=foo mode=0644 - file: src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link - file: src=/tmp/{{ item.path }} dest={{ item.dest }} state=link with_items: - { path: ’x’, dest: ’y’ } - { path: ’z’, dest: ’k’ } Note: See also copy , template , assemble ini_file - Tweak settings in INI files Author Jan-Piet Mens 1.6. Module Index 395
Image of page 399
Ansible Documentation, Release 1.7 • Synopsis • Options • Examples Synopsis Manage (add, remove, change) individual settings in an INI-style file without having to manage the file as a whole with, say, template or assemble . Adds missing sections if they don’t exist. Comments are discarded when the source file is read, and therefore will not show up in the destination file. Options Note: Requires ConfigParser Examples # Ensure "fav=lemonade is in section "[drinks]" in specified file - ini_file: dest=/etc/conf section=drinks option=fav value=lemonade mode=0600 backup=yes - ini_file: dest=/etc/anotherconf section=drinks option=temperature value=cold backup=yes Note: While it is possible to add an option without specifying a value , this makes no sense. Note: A section named default cannot be added by the module, but if it exists, individual options within the section can be updated. (This is a limitation of Python’s ConfigParser .) Either use template to create a base INI file with a [default] section, or use lineinfile to add the missing line. lineinfile - Ensure a particular line is in a file, or replace an existing line using a back-referenced regular expression. Author Daniel Hokka Zakrisson, Ahti Kitsik • Synopsis • Options • Examples Synopsis This module will search a file for a line, and ensure that it is present or absent. This is primarily useful when you want to change a single line in a file only. For other cases, see the copy or template modules.
Image of page 400
Image of page 401

You've reached the end of your free preview.

Want to read all 572 pages?

  • Spring '17
  • Redhat
  • Ansible, Secure Shell, ansible documentation

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture