带有 ansible 的 sshfs 给出的结果与 运行 在主机上手动给出的结果不同
sshfs with ansible does not give the same result as running it manually on the host
我正在为我的服务器做备份。我为此使用 sshfs。当想要备份文件夹时,备份服务器会要求输入密码。这是我的任务(处理程序)的样子:
- name: Mount backup folder
become: yes
expect:
command: "sshfs -o allow_other,default_permissions {{ backup_server.user }}@{{ backup_server.host }}:/ /mnt/backup"
echo: yes
responses:
(.*)password(.*): "{{ backup_server.password }}"
(.*)Are you sure you want to continue(.*): "yes"
listen: mount-backup-folder
它 运行s 并产生这个输出:
changed: [prod1.com] => {
"changed": true,
"cmd": "sshfs -o allow_other,default_permissions user@hostname.com:/ /mnt/backup",
"delta": "0:00:00.455753",
"end": "2021-01-26 14:57:34.482440",
"invocation": {
"module_args": {
"chdir": null,
"command": "sshfs -o allow_other,default_permissions user@hostname.com:/ /mnt/backup",
"creates": null,
"echo": true,
"removes": null,
"responses": {
"(.*)Are you sure you want to continue(.*)": "yes",
"(.*)password(.*)": "password"
},
"timeout": 30
}
},
"rc": 0,
"start": "2021-01-26 14:57:34.026687",
"stdout": "user@hostname.com's password: ",
"stdout_lines": [
"user@hostname.com's password: "
]
}
但是当我转到服务器时,文件夹没有与备份服务器同步。但是当我手动 运行 命令时:
sshfs -o allow_other,default_permissions user@hostname.com:/ /mnt/backup
备份确实有效。有人知道这是怎么可能的吗?
我正在为我的服务器做备份。我为此使用 sshfs。当想要备份文件夹时,备份服务器会要求输入密码。这是我的任务(处理程序)的样子:
- name: Mount backup folder
become: yes
expect:
command: "sshfs -o allow_other,default_permissions {{ backup_server.user }}@{{ backup_server.host }}:/ /mnt/backup"
echo: yes
responses:
(.*)password(.*): "{{ backup_server.password }}"
(.*)Are you sure you want to continue(.*): "yes"
listen: mount-backup-folder
它 运行s 并产生这个输出:
changed: [prod1.com] => {
"changed": true,
"cmd": "sshfs -o allow_other,default_permissions user@hostname.com:/ /mnt/backup",
"delta": "0:00:00.455753",
"end": "2021-01-26 14:57:34.482440",
"invocation": {
"module_args": {
"chdir": null,
"command": "sshfs -o allow_other,default_permissions user@hostname.com:/ /mnt/backup",
"creates": null,
"echo": true,
"removes": null,
"responses": {
"(.*)Are you sure you want to continue(.*)": "yes",
"(.*)password(.*)": "password"
},
"timeout": 30
}
},
"rc": 0,
"start": "2021-01-26 14:57:34.026687",
"stdout": "user@hostname.com's password: ",
"stdout_lines": [
"user@hostname.com's password: "
]
}
但是当我转到服务器时,文件夹没有与备份服务器同步。但是当我手动 运行 命令时:
sshfs -o allow_other,default_permissions user@hostname.com:/ /mnt/backup
备份确实有效。有人知道这是怎么可能的吗?