saltstack / saltstack/salt

Windows: file.replace needs 3 runs

Open
#52,457 3 comments 0 reactions 1 assignee View on GitHub

@twangboy is already working on this.

Since Apr 9, 2019.

bug severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

When modifying a file with file.replace on Windows, the first 2 runs modify the file and the 3rd run reports the files as "Clean". On Linux, this already happens at the 2nd run, as expected.

Setup

Here's a simple SLS file to reproduce the issue:

{%- if grains['kernel'] == 'Windows' %}
  {%- set drive = 'C:' %}
{%- else %}
  {%- set drive = '' %}
{%- endif %}

create_file:
  file.managed:
    - name: {{ drive }}/tmp/pg_hba.conf
    - makedirs: True

allow_ipv4:
  file.replace:
    - name: {{ drive }}/tmp/pg_hba.conf
    - repl: host    all             all             0.0.0.0/0               md5
    - pattern: ^host\s+all\s+all\s+0\.0\.0\.0/0\s+md5.*
    - append_if_not_found: True
    - require:
      - file: create_file

allow_ipv6:
  file.replace:
    - name: {{ drive }}/tmp/pg_hba.conf
    - repl: host    all             all             ::/0                    md5
    - pattern: ^host\s+all\s+all\s+::/0\s+md5.*
    - append_if_not_found: True
    - require:
      - file: create_file
Steps to Reproduce Issue

Apply above state to a Linux and a Windows minion multiple times. Windows will need 3 tries to show that everything is in desired state, while Linux needs 2.

Versions Report
>salt-call --versions-report
Salt Version:
           Salt: 2018.3.3

Dependency Versions:
           cffi: 1.10.0
       cherrypy: 10.2.1
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.5
      gitpython: 2.1.3
          ioflo: Not Installed
         Jinja2: 2.9.6
        libgit2: Not Installed
        libnacl: 1.6.1
       M2Crypto: Not Installed
           Mako: 1.0.6
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.17
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.3
           RAET: Not Installed
          smmap: 2.0.5
        timelib: 0.2.4
        Tornado: 4.5.1
            ZMQ: 4.1.6

System Versions:
           dist:
         locale: cp1252
        machine: AMD64
        release: 2016Server
         system: Windows
        version: 2016Server 10.0.14393 SP0 Multiprocessor Free

Also happens with 2018.3.4.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.