New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state file.line has error and erase file content completly, while with mode test=true it is ok #48113

Closed
gaetanquentin opened this Issue Jun 13, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@gaetanquentin

gaetanquentin commented Jun 13, 2018

Trying to insert lines after line "symbolic-links=0":

file to modify:

/etc/my.cnf:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

state:

installation de mysql:
   pkg.installed:
     - pkgs:
        - mysql-server
        - MySQL-python
        - libselinux-python

/etc/my.cnf:
  file.line:
    - mode: ensure
    - content: |
        skip-name-resolve
        default-time-zone=’+00:00′
        innodb_rollback_on_timeout=1
        innodb_lock_wait_timeout=600
        max_connections=350
        log-bin=mysql-bin
        binlog-format = ‘ROW’
    - after: symbolic-links=0

Results

  • with test=true: result is ok:
salt 'apache-cloudstack' state.apply cloudstack test=true
apache-cloudstack:
----------
          ID: installation de mysql
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed
     Started: 00:03:19.953083
    Duration: 523.588 ms
     Changes:   
----------
          ID: /etc/my.cnf
    Function: file.line
      Result: None
     Comment: Changes would be made:
              diff:
              --- 
              +++ 
              @@ -4,6 +4,13 @@
               user=mysql
               # Disabling symbolic-links is recommended to prevent assorted security risks
               symbolic-links=0
              +skip-name-resolve
              +default-time-zone=’+00:00′
              +innodb_rollback_on_timeout=1
              +innodb_lock_wait_timeout=600
              +max_connections=350
              +log-bin=mysql-bin
              +binlog-format = ‘ROW’
               
               [mysqld_safe]
               log-error=/var/log/mysqld.log
     Started: 00:03:20.485878
    Duration: 1.162 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -4,6 +4,13 @@
                   user=mysql
                   # Disabling symbolic-links is recommended to prevent assorted security risks
                   symbolic-links=0
                  +skip-name-resolve
                  +default-time-zone=’+00:00′
                  +innodb_rollback_on_timeout=1
                  +innodb_lock_wait_timeout=600
                  +max_connections=350
                  +log-bin=mysql-bin
                  +binlog-format = ‘ROW’
                   
                   [mysqld_safe]
                   log-error=/var/log/mysqld.log
  • without test=true, error, and file is empty:
salt 'apache-cloudstack' state.apply cloudstack 
apache-cloudstack:
----------
          ID: installation de mysql
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed
     Started: 23:51:14.803104
    Duration: 505.11 ms
     Changes:   
----------
          ID: /etc/my.cnf
    Function: file.line
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1905, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1830, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/file.py", line 3933, in line
                  backup=backup, quiet=quiet, indent=indent)
                File "/usr/lib/python2.7/site-packages/salt/modules/file.py", line 2048, in line
                  fh_.write(body)
              UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 206: ordinal not in range(128)
     Started: 23:51:15.317590
    Duration: 3.789 ms
     Changes:   
[root@apache-cloudstack ~]# cat /etc/my.cnf
[root@apache-cloudstack ~]# 

environment

#salt master:
 ubuntu,16.04
 salt in  python3:
root@salt:/data/repositories/automation/salt/states/cloudstack# salt --versions-report
Salt Version:
           Salt: 2018.3.1
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: 3.5.0
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.5.2 (default, Nov 23 2017, 16:37:01)
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: Ubuntu 16.04 xenial
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-20-generic
         system: Linux
        version: Ubuntu 16.04 xenial

salt minion:
centos 6
salt in python 2:

[root@apache-cloudstack ~]# salt-call --versions-report
Salt Version:
           Salt: 2018.3.1
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Mar 30 2018, 15:31:59)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.5.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
 
System Versions:
           dist: centos 6.9 Final
         locale: ANSI_X3.4-1968
        machine: x86_64
        release: 4.15.0-20-generic
         system: Linux
        version: CentOS 6.9 Final
@garethgreenaway

This comment has been minimized.

Member

garethgreenaway commented Jun 14, 2018

@gaetanquentin Thanks for the report. We'll get this one fixed up asap.

@rallytime

This comment has been minimized.

Contributor

rallytime commented Jun 17, 2018

@gaetanquentin This should be fixed with #48156.

@rallytime rallytime closed this Sep 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment