file.line replace mode does not work!
Description of Issue/Question
I am trying to use the file.line state to replace a line in a file but it does not seem to work
Setup
I am trying to make changes in multiple lines in the same files. there is not easier way of doing that without managing the entire file, so I have multiple states like the one below, non seem to behave as expected:
ssl_conf1:
file.line:
- name: /etc/httpd/conf.d/ssl.conf
- match: "^SSLCertificateFile /etc/pki/tls/certs/localhost.crt"
- mode: replace
- content: |
# Salt - one-time modification performed on {{ salt['cmd.run']('date') }}
#SSLCertificateFile /etc/pki/tls/certs/{{ grains['fqdn'] }}.crt
Steps to Reproduce Issue
Every time the above state runs I see the following lines in the log:
2016-07-21 14:48:53,297 [salt.state ][INFO ][30411] Running state [/etc/httpd/conf.d/ssl.conf] at time 14:48:53.296618
2016-07-21 14:48:53,297 [salt.state ][INFO ][30411] Executing state file.line for /etc/httpd/conf.d/ssl.conf
2016-07-21 14:48:53,298 [salt.state ][INFO ][30411] No changes needed to be made
2016-07-21 14:48:53,298 [salt.state ][INFO ][30411] Completed state [/etc/httpd/conf.d/ssl.conf] at time 14:48:53.297924 duration_in_ms=1.306
Even though the search patter exists in file and is not replaced with the desired contents. The same happens if I use a one-line content.
Versions Report
versions report on the master:
Salt Version:
Salt: 2016.3.1
Dependency Versions:
cffi: Not Installed
cherrypy: 3.2.2
dateutil: 1.4.1
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
Jinja2: 2.7.3
libgit2: 0.20.0
libnacl: Not Installed
M2Crypto: 0.20.2
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: 0.20.3
Python: 2.6.6 (r266:84292, May 22 2015, 08:34:51)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
RAET: Not Installed
smmap: 0.8.1
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: redhat 6.8 Santiago
machine: x86_64
release: 2.6.32-642.1.1.el6.x86_64
system: Linux
version: Red Hat Enterprise Linux Server 6.8 Santiago
versions report on the minion:
Salt Version:
Salt: 2016.3.1
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 1.5
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.7
mysql-python: 1.2.3
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.5 (default, Oct 11 2015, 17:47:16)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.7.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: redhat 7.2 Maipo
machine: x86_64
release: 3.10.0-327.22.2.el7.x86_64
system: Linux
version: Red Hat Enterprise Linux Server 7.2 Maipo
@aabognah I think you just need to add a couple of spaces to content like so:
- content: |
# Salt - one-time modification performed on {{ salt['cmd.run']('date') }}
#SSLCertificateFile /etc/pki/tls/certs/{{ grains['fqdn'] }}.crt
Does that work?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.