我有一个 Ansible 剧本(Ansible 版本 2.9.27),它使用同步模块来备份文件。该剧本用于从各种融合组件中备份各种融合属性和其他信息。
剧本在一个环境中成功运行,但在另一个环境中要求输入密码并基本挂起。
我已经使用
ansible -i hosts.yml all -m ping
验证目标的无密码 ssh 设置并成功运行。
我检查了两个环境中的rsync版本,两个地方的版本相同-
rsync version 3.1.2 protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes, prealloc
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
这是剧本
---
- name: Backup properties files, masterkey and passphrase fils and iverride.conf files as well as data from zookeeper
hosts: all
tasks:
- name : get the timestamp once
set_fact:
backupts: "{{lookup('pipe','date +%Y%m%d-%H%M%S')}}"
run_once: true
delegate_to: localhost
- debug:
msg: "backupts: -> {{ backupts }}"
run_once: true
delegate_to: localhost
# Ultimately set the inv_host_path variable to /software/scripts/confl-backup-5.5.1
- name: set other facts
set_fact:
inv_host_path: "/software/confl-backup-5.5.1/properties-backup_{{ backupts }}/{{ inventory_hostname }}/"
inv_host_path_test: "/export/home/svcuser/tmp/software/properties-backup_{{ backupts }}/{{ inventory_hostname }}/"
systemd_path: "/etc/systemd/system/"
zookeeper_data_path: "/var/lib/zookeeper/version-2/"
ansible_password: password
- name: Cretate /etc under backup path directories to backup kafka and confluent* subdirectories under /etc directory.
file:
path: "{{ inv_host_path }}/etc/"
state: directory
delegate_to: localhost
- name: Download /etc/.
#https://stackoverflow.com/questions/25505146/how-to-copy-files-between-two-nodes-using-ansible
synchronize:
src: "/etc/{{ item }}"
dest: "{{ inv_host_path }}/etc/"
# rsync_path: "sudo rsync"
mode: pull
with_items:
- kafka
- confluent*
delegate_to: localhost
register: etc_output
- name: Cretate /etc/systemd/system/ under backup path directories to backup override.conf files from /etc/systemd/system/ directory .
file:
path: "{{ inv_host_path }}{{ systemd_path }}"
state: directory
delegate_to: localhost
- name: Download /etc/systemd/system/.
synchronize:
src: "{{ systemd_path }}{{ item }}"
dest: "{{ inv_host_path }}{{ systemd_path }}"
# rsync_path: "sudo rsync"
mode: pull
with_items:
- confluent*
delegate_to: localhost
register: etc_systemd_system_output
- name: backup zookeeper data dir
hosts: zookeeper
tasks:
- name: Cretate /var/lib/zookeeper/version-2/ under backup path directories to backup data from /var/lib/zookeeper/version-2/ directory ..
file:
path: "{{ inv_host_path }}{{ zookeeper_data_path }}"
state: directory
delegate_to: localhost
# check if directory exists
- name: check if directory exists
stat:
path: "{{ zookeeper_data_path }}"
become: yes
register: zookeeper_data_dir_stat
- name: synchronise files in one loop
synchronize:
# src: "{{ item.src }}{{ item.syncpattern }}"
src: "{{ item.src }}"
dest: "{{ item.dest }}"
# rsync_path: "sudo rsync"
mode: pull
rsync_opts:
- "--include={{ item.src }}snapshot.*"
- "--exclude={{ item.src }}log.*"
delegate_to: localhost
loop:
- { src: "{{ zookeeper_data_path }}", dest: "{{ inv_host_path }}{{ zookeeper_data_path }}", syncpattern: 'snapshot.*' }
when: zookeeper_data_dir_stat.stat.exists
register: zookeeper_data_output
我在行之有效的行中没有这一行就环境设置而言,我需要检查什么?已尝试删除 rsync_path,将“ansible_password”添加为 set-fact 变量——尽管我无法将其保留在最终版本中,只是想尝试一下。它们都没有在第二个环境中起作用。
关于如何找出实际的潜在问题有什么建议吗?