python 2.7 - modifying apache ports.conf via fabric script -
i automating deploy of site requires me add listen port ports.conf. right ok me replace existing 1 new sites added able modify file. have seen examples of creating backup of file , writing-out modified file in python. seems me of way there and, python-wise, i'm sure can figure out rest. (making sure change hasn't been made, etc.) however, i'm not sure doing in fabric. how go executing block of python code remotely?
if need add line configuration file (and nothing if it's there), can use append
function in fabric.contrib.files
.
example:
from fabric.contrib.files import append append('/etc/apache2/ports.conf', 'listen 1234', use_sudo=true)
see http://docs.fabfile.org/en/1.7/api/contrib/files.html#fabric.contrib.files.append
Comments
Post a Comment