Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Synchronize of ansile (2) module

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The effect of ansible synchronize is similar to that of rsync. The specific parameters are as follows:

The contents of the parameters are all from the official website. If there is any discrepancy, the official website is the main one.

Parameters.

Whether the default option description archivenoyes is required

Yes

No

Rsync mirror recursion flag, enable recursion, link, permission, time, owner, group flag and-Dchecksumnono

Yes

No

Skip the basic check

Compressnoyes

Yes

No

Compress file data during transfer. In most cases, keep it enabled unless it causes a problem. Copy_linksnono

Yes

No

Copy symbolic links to the items they point to (reference objects) instead of symbolic links. Deletenono

Yes

No

Delete files in dest that do not exist in the src path (not before after transfer). This option requires recursive = yes. Destyes

The path on the destination host of the source to be synchronized; the path can be absolute or relative. Dest_portnoansible_ssh_port value settings, remote_port configuration settings, if the ssh client does not have a setting

The port number of the ssh on the target host. Before ansible 2. 0, the ansible_ssh_port inventory variable took precedence over this value. Dirsnono

Yes

No

Transfer directories without recursive existing_onlynono

Yes

No

Skip creating a new file on the receiver. The value of the groupno recursive option

Yes

No

Reserved group

The value of the linksno recursive option

Yes

No

Copy a symbolic link as a symbolic link. Modenopush

Yes

No

Specifies the direction of synchronization. In push mode, localhost or delegate is the source; in pull mode, the remote host is the source in context. The value of the ownerno recursive option

Yes

No

Retain the owner

Partialno

Tell rsync to keep some files, which should make the rest of the file transfer later. The value of the permsno recursive option

Yes

No

Retain permissions

The value of the recursiveno recursive option

Yes

No

Recursively to the directory. Rsync_optsno

Specify additional rsync options by passing in an array. Rsync_pathno

Specifies the rsync command to run on the remote host. See-- rsync-path on the rsync man page. Rsync_timeoutno

Specifies the-- timeout of the rsync command in seconds. Set_remote_usernoTrue

Put user @ is the remote path. If you have a custom ssh configured to define a remote user on a host that does not match the inventory user, you should set this parameter to no. Srcyes

The path that will be synchronized to the source host of the destination; the path can be absolute or relative. The value of the timesno recursive option

Yes

No

Save modification time

Use_ssh_argsnono

Yes

No

Use the ssh_argsverify_hostno specified in ansible.cfg

Verify the target host key.

1. Synchronize the files in the directory:

Source file:

# lltotal 4lrwxrwxrwx 1 root root 8 Dec 28 17:39 fk-> / data/fm-rw-r--r-- 1 root root 4096 May 31 2016 p.txt

Synchronize the files in the directory instead of the directory:

# ansible webserver-m synchronize-a "src=/root/dog/ dest=/tmp/" 172.16.110.48 | SUCCESS = > {"changed": true, "cmd": "/ usr/bin/rsync-- delay-updates-F-compress-- archive-- rsh 'ssh-S none-o StrictHostKeyChecking=no'-out-format='%i% n% L'\" / root/dog/\ "\" 172.16.110.48:/tmp/\ "" "msg": ".d.t. . /\ n "," rc ": 0," stdout_lines ": [" .d.t. . / "]} 172.16.110.47 | SUCCESS = > {" changed ": true," cmd ":" / usr/bin/rsync-- delay-updates-F-- compress-- archive-- rsh 'ssh-S none-o StrictHostKeyChecking=no'-- out-format='%i% n% L'\ "/ root/dog/\"\ "172.16.110.47:/tmp/\", "msg": ".d.t. . /\ n "," rc ": 0," stdout_lines ": [" .d.t. . / "]}

Synchronized all files

# lltotal 8drwxr-xr-x 2 root root 29 Dec 28 17:39 doglrwxrwxrwx 1 root root 8 Dec 28 17:39 fk-> / data/fm / / invalid link, source does not exist

two。 Synchronize the entire directory:

# ansible webserver-m synchronize-a "src=/root/dog dest=/tmp/" 172.16.110.48 | SUCCESS = > {"changed": true, "cmd": "/ usr/bin/rsync-- delay-updates-F-compress-- archive-- rsh 'ssh-S none-o StrictHostKeyChecking=no'-out-format='%i% n% L'\" / root/dog\ "\" 172.16.110.48:/tmp/\ "" "msg": "cd+ dog/\ ncL+ dog/fk-> / data/fm\ n / data/fm", "/ data/fm\ n / data/fm", "

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report