Role - tripleo-transfer

Role Documentation

Welcome to the “tripleo_transfer” role documentation.

Role Defaults

This section highlights all of the defaults and variables set within the “tripleo_transfer” role.

# All variables intended for modification should be placed in this file.


# Required variables:
#   * `tripleo_transfer_src_host` -- the inventory name of the source host
#   * `tripleo_transfer_src_dir` -- directory on the source host to transfer from
#   * `tripleo_transfer_dest_host` -- the inventory name of the destination host
#   * `tripleo_transfer_dest_dir` -- directory on the destination host to transfer to
tripleo_transfer_debug: '{{ ((ansible_verbosity | int) >= 2) | bool }}'
tripleo_transfer_src_become: true
tripleo_transfer_dest_become: true
tripleo_transfer_flag_file:
# tripleo_transfer_key_location: location of the private key used to connect
# from src host to dest host.
tripleo_transfer_key_location: ~/transfer_key
# tripleo_transfer_cleanup_keys: clean up the keypair from the source host
# and remove public key from destination host when true.
tripleo_transfer_cleanup_keys: true
# tripleo_transfer_exclude: a list of patterns to selectively exclude
# some files from the transfer to the destination host.
tripleo_transfer_exclude: []
# tripleo_transfer_include: a list of patterns to selectively include
# some files from the transfer to the destination host. Files in this list
# are not filtered out with tripleo_transfer_exclude.
tripleo_transfer_include: []
# tripleo_transfer_sync_options: override default transfer options
tripleo_transfer_sync_options: --delay-updates -F --ignore-times --compress --archive
  --delete

Role Variables: main.yml

# All variables intended for internal use should be placed in this file.


# make sure we have a trailing forward slash in the src, otherwise rsync creates extra dir
tripleo_transfer_src_dir_safe: '{{ tripleo_transfer_src_dir }}/'

# make sure we do not have a trailing forward slash in the dest
tripleo_transfer_dest_dir_safe: "{{ tripleo_transfer_dest_dir | regex_replace('\\\
  /$', '') }}"

Molecule Scenarios

Molecule is being used to test the “tripleo_transfer” role. The following section highlights the drivers in service and provides an example playbook showing how the role is leveraged.

Scenario: default

Driver: delegated
Molecule Options
managed: false
login_cmd_template: >-
  ssh
  -o UserKnownHostsFile=/dev/null
  -o StrictHostKeyChecking=no
  -o Compression=no
  -o TCPKeepAlive=yes
  -o VerifyHostKeyDNS=no
  -o ForwardX11=no
  -o ForwardAgent=no
  {instance}
ansible_connection_options:
  ansible_connection: ssh
Molecule Inventory
hosts:
  all:
    hosts:
      controller1:
        ansible_host: 127.0.0.2
      controller2:
        ansible_host: 127.0.0.3
    vars:
      test_src_dir: /tmp/src_files
      test_src_files:
      - testfile1
      - testfile2
      - testfile3
      test_dst_dir: /tmp/dst_files
      test_dst_files:
      - testfile4
      - testfile5
      - testfile6
      test2_src_dir: /tmp/src_files_2
      test2_dst_dir: /tmp/dst_files_2
      test2_src_files:
      - transferred
      test2_exclude_src_files:
      - skip1
      - skip2
      - donotcopy
      test2_include_pattern:
      - transferred
      test2_exclude_pattern:
      - skip*
      - donotcopy
Example default playbook
- name: Collect facts
  hosts: all
  gather_facts: false
  any_errors_fatal: true
  tasks:
  - name: Gather a minimal set of facts
    setup:
      gather_subset: '!all,min'

- name: Converge
  hosts: localhost
  connection: local
  any_errors_fatal: true
  tasks:
  - name: Install openssl for file creation
    package:
      name: openssl
      state: present
    become: true

  - name: Create test directories
    file:
      state: directory
      path: '{{ item }}'
    loop:
    - '{{ test_src_dir }}'
    - '{{ test_dst_dir }}'
    - '{{ test2_src_dir }}'
    - '{{ test2_dst_dir }}'

  - name: Create 1GB src test files with random content
    shell: >-
      openssl rand -out {{ item }} -base64 $(( 2**30 * 3/4 ))
    args:
      chdir: '{{ test_src_dir }}'
      creates: '{{ item }}'
    loop: '{{ test_src_files }}'

  - name: Create empty dst test files with random content
    file:
      path: '{{ test_dst_dir }}/{{ item }}'
      state: touch
    loop: '{{ test_dst_files }}'

  - include_role:
      name: tripleo_transfer
    vars:
      tripleo_transfer_src_host: controller2
      tripleo_transfer_src_dir: '{{ test_src_dir }}'
      tripleo_transfer_dest_host: controller1
      tripleo_transfer_dest_dir: '{{ test_dst_dir }}'

  - name: Create empty src test files
    file:
      state: touch
      path: '{{ test2_src_dir }}/{{ item }}'
    loop: '{{ test2_src_files + test2_exclude_src_files }}'

  - include_role:
      name: tripleo_transfer
    vars:
      tripleo_transfer_src_host: controller2
      tripleo_transfer_src_dir: '{{ test2_src_dir }}'
      tripleo_transfer_dest_host: controller1
      tripleo_transfer_dest_dir: '{{ test2_dst_dir }}'
      tripleo_transfer_exclude: '{{ test2_exclude_pattern }}'
      tripleo_transfer_include: '{{ test2_include_pattern }}'