fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] Non-atomic put() operation in Fabric 1.14.0


From: Gena Makhomed
Subject: [Fab-user] Non-atomic put() operation in Fabric 1.14.0
Date: Sun, 15 Oct 2017 16:01:39 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

Hello, All!

I am try to use Fabric 1.13.2 / 1.14.0
for Configuration Management and Server provisioning.

But as I can see, put() operation is non-atomic,
so configuration files on remote server can be corrupted.

Non-atomic put() operation - this is a bug in Fabric code?
Should I report this bug via https://github.com/fabric/fabric/issues ?

Or this is not bug, but "feature",
and I should create workaround for this "feature" in my own code?

Something like this: put(..., atomic=True, ...)

- if destination file has multiple hard links:
    abort execution with fatal error,
    because we can't atomically replace such file
  else:
- upload new file to file with temporary name on remote server
- run( chown new file using old file as --reference= )
- run( chmod new file using old file as --reference= )
- if linux extended attributes is supported:
    getfacl oldfile > tmpfile.facl ; setfacl --restore=tmpfile.facl
- if selinux enabled, run:
    chcon --reference=/path/to/oldfile /path/to/a/newfile
- and finally, run( mv /path/to/newfile /path/to/oldfile )

In such way I can atomically replace edited file at remote host.

P.S.

Both, Ansible and CFEngine make atomic file updates on remote servers:

http://docs.ansible.com/ansible/latest/replace_module.html

https://docs.cfengine.com/docs/3.10/reference-promise-types-edit_line.html

--
Best regards,
 Gena



reply via email to

[Prev in Thread] Current Thread [Next in Thread]