0

I'm new on SaltStack and I have to install a database server with salt. Installing packages is not a problem but I don't succeed to configure root password after the installation.

I saw many articles where they talk about the mysql_user.present state like here How to set root password using salt states :

  mysql_user.present:
    - host: localhost
    - password: s3cure_root_password

or using debconf-utils like here http://terokarvinen.com/2018/mysql-automatic-install-with-salt-preseed-database-root-password but it doesn't work for me everytime.

Any ideas to do that ?

The first way return me that :

Function: mysql_user.present
Name: root
Result: False
Comment: MySQL Error 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)```

1 Answers1

0

I tried to install it with the saltstack mysql formula https://github.com/saltstack-formulas/mysql-formula

But there are errors too...

salt-minion-2:
----------
          ID: mysql_debconf_utils
    Function: pkg.installed
        Name: debconf-utils
      Result: True
     Comment: All specified packages are already installed
     Started: 15:55:13.882198
    Duration: 32.065 ms
     Changes:
----------
          ID: mysql_debconf
    Function: debconf.set
        Name: mariadb-server
      Result: True
     Comment:
     Started: 15:55:13.914531
    Duration: 210.382 ms
     Changes:
              ----------
              mariadb-server/start_on_boot:
                  true
----------
          ID: mysqld-packages
    Function: pkg.installed
        Name: mariadb-server
      Result: True
     Comment: The following packages were installed/updated: mariadb-server
     Started: 15:55:14.125284
    Duration: 35160.726 ms
     Changes:
              ----------
              galera-3:
                  ----------
                  new:
                      25.3.25-2
                  old:
              gawk:
                  ----------
                  new:
                      1:4.2.1+dfsg-1
                  old:
              libaio1:
                  ----------
                  new:
                      0.3.112-3
                  old:
              libcgi-fast-perl:
                  ----------
                  new:
                      1:2.13-1
                  old:
              libcgi-pm-perl:
                  ----------
                  new:
                      4.40-1
                  old:
              libconfig-inifiles-perl:
                  ----------
                  new:
                      3.000001-1
                  old:
              libdbd-mysql-perl:
                  ----------
                  new:
                      4.050-2
                  old:
              libdbi-perl:
                  ----------
                  new:
                      1.642-1+b1
                  old:
              libencode-locale-perl:
                  ----------
                  new:
                      1.05-1
                  old:
              libfcgi-perl:
                  ----------
                  new:
                      0.78-2+b3
                  old:
              libgdbm-compat4:
                  ----------
                  new:
                      1.18.1-4
                  old:
              libgdbm6:
                  ----------
                  new:
                      1.18.1-4
                  old:
              libhtml-parser-perl:
                  ----------
                  new:
                      3.72-3+b3
                  old:
              libhtml-tagset-perl:
                  ----------
                  new:
                      3.20-3
                  old:
              libhtml-template-perl:
                  ----------
                  new:
                      2.97-1
                  old:
              libhttp-date-perl:
                  ----------
                  new:
                      6.02-1
                  old:
              libhttp-message-perl:
                  ----------
                  new:
                      6.18-1
                  old:
              libio-html-perl:
                  ----------
                  new:
                      1.001-1
                  old:
              liblwp-mediatypes-perl:
                  ----------
                  new:
                      6.02-1
                  old:
              libmariadb3:
                  ----------
                  new:
                      1:10.3.22-0+deb10u1
                  old:
              libmpfr6:
                  ----------
                  new:
                      4.0.2-1
                  old:
              libperl5.28:
                  ----------
                  new:
                      5.28.1-6
                  old:
              libreadline5:
                  ----------
                  new:
                      5.2+dfsg-3+b13
                  old:
              libsigsegv2:
                  ----------
                  new:
                      2.12-2
                  old:
              libsnappy1v5:
                  ----------
                  new:
                      1.1.7-1
                  old:
              libterm-readkey-perl:
                  ----------
                  new:
                      2.38-1
                  old:
              libtimedate-perl:
                  ----------
                  new:
                      2.3000-2+deb10u1
                  old:
              liburi-perl:
                  ----------
                  new:
                      1.76-1
                  old:
              lsof:
                  ----------
                  new:
                      4.91+dfsg-1
                  old:
              mariadb-client-10.3:
                  ----------
                  new:
                      1:10.3.22-0+deb10u1
                  old:
              mariadb-client-core-10.3:
                  ----------
                  new:
                      1:10.3.22-0+deb10u1
                  old:
              mariadb-common:
                  ----------
                  new:
                      1:10.3.22-0+deb10u1
                  old:
              mariadb-server:
                  ----------
                  new:
                      1:10.3.22-0+deb10u1
                  old:
              mariadb-server-10.3:
                  ----------
                  new:
                      1:10.3.22-0+deb10u1
                  old:
              mariadb-server-core-10.3:
                  ----------
                  new:
                      1:10.3.22-0+deb10u1
                  old:
              mysql-common:
                  ----------
                  new:
                      5.8+1.0.5
                  old:
              perl:
                  ----------
                  new:
                      5.28.1-6
                  old:
              perl-modules-5.28:
                  ----------
                  new:
                      5.28.1-6
                  old:
              psmisc:
                  ----------
                  new:
                      23.2-1
                  old:
              rsync:
                  ----------
                  new:
                      3.1.3-6
                  old:
              socat:
                  ----------
                  new:
                      1.7.3.2-2
                  old:
----------
          ID: mysql_config
    Function: file.managed
        Name: ~/.my.cnf
      Result: True
     Comment: File /root/.my.cnf updated
     Started: 15:55:49.288012
    Duration: 129.805 ms
     Changes:
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: mysql_python
    Function: pkg.installed
        Name: python3-mysqldb
      Result: True
     Comment: The following packages were installed/updated: python3-mysqldb
     Started: 15:55:49.421607
    Duration: 1451.415 ms
     Changes:
              ----------
              python3-mysqldb:
                  ----------
                  new:
                      1.3.10-2
                  old:
----------
          ID: mysql_additional_config
    Function: file.managed
        Name: /usr/my.cnf
      Result: True
     Comment: File /usr/my.cnf is not present and is not set for creation
     Started: 15:55:50.881986
    Duration: 0.727 ms
     Changes:
----------
          ID: mysqld-service-running
    Function: service.running
        Name: mariadb
      Result: True
     Comment: Service restarted
     Started: 15:55:50.901574
    Duration: 2393.114 ms
     Changes:
              ----------
              mariadb:
                  True
----------
          ID: mysql_what_is_status_of_mariadb
    Function: cmd.run
        Name: service mariadb status
      Result: True
     Comment: State was not run because onfail req did not change
     Started: 16:13:54.339482
    Duration: 0.004 ms
     Changes:
----------
          ID: mysql_salt_user_with_salt_user
    Function: mysql_user.present
        Name: salt
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.339827
    Duration: 2.907 ms
     Changes:
----------
          ID: mysql_salt_user_with_salt_user_grants
    Function: mysql_grants.present
        Name: salt
      Result: False
     Comment: One or more requisite failed: mysql.salt-user.mysql_salt_user_with_salt_user
     Started: 16:13:54.343410
    Duration: 0.002 ms
     Changes:
----------
          ID: mysql_salt_user_with_root_user
    Function: mysql_user.present
        Name: salt
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'root'@'localhost'
     Started: 16:13:54.343449
    Duration: 232.786 ms
     Changes:
----------
          ID: mysql_salt_user_with_root_user_grants
    Function: mysql_grants.present
        Name: salt
      Result: False
     Comment: One or more requisite failed: mysql.salt-user.mysql_salt_user_with_root_user
     Started: 16:13:54.576755
    Duration: 0.003 ms
     Changes:
----------
          ID: mysql_salt_user_with_passwordless_root_user
    Function: mysql_user.present
        Name: salt
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'root'@'localhost'
     Started: 16:13:54.576792
    Duration: 20.922 ms
     Changes:
----------
          ID: mysql_salt_user_with_passwordless_root_user_grants
    Function: mysql_grants.present
        Name: salt
      Result: False
     Comment: One or more requisite failed: mysql.salt-user.mysql_salt_user_with_passwordless_root_user
     Started: 16:13:54.598244
    Duration: 0.002 ms
     Changes:
----------
          ID: mysql_db_0
    Function: mysql_database.present
        Name: foo
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.598721
    Duration: 1.232 ms
     Changes:
----------
          ID: mysql_db_0_schema
    Function: file.managed
        Name: /etc/mysql/foo.schema
      Result: False
     Comment: Source file salt://./files/foo.schema not found in saltenv 'base'
     Started: 16:13:54.600032
    Duration: 5.801 ms
     Changes:
----------
          ID: mysql_db_0_load
    Function: cmd.wait
        Name: mysql -u salt -h127.0.0.1 -psomeotherpass foo < /etc/mysql/foo.schema
      Result: False
     Comment: One or more requisite failed: mysql.database.mysql_db_0_schema, mysql.database.mysql_db_0
     Started: 16:13:54.606295
    Duration: 0.002 ms
     Changes:
----------
          ID: mysql_db_1
    Function: mysql_database.present
        Name: bar
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.606714
    Duration: 1.451 ms
     Changes:
----------
          ID: mysql_db_2
    Function: mysql_database.absent
        Name: obsolete_db
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.608636
    Duration: 1.139 ms
     Changes:
----------
          ID: mysql_user_frank_localhost
    Function: mysql_user.present
        Name: frank
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.610228
    Duration: 1.229 ms
     Changes:
----------
          ID: mysql_user_frank_localhost_0
    Function: mysql_grants.present
        Name: frank_foo_all
      Result: False
     Comment: One or more requisite failed: mysql.user.mysql_user_frank_localhost
     Started: 16:13:54.611764
    Duration: 0.002 ms
     Changes:
----------
          ID: mysql_user_frank_localhost_1
    Function: mysql_grants.present
        Name: frank_bar_all
      Result: False
     Comment: One or more requisite failed: mysql.user.mysql_user_frank_localhost
     Started: 16:13:54.611882
    Duration: 0.001 ms
     Changes:
----------
          ID: mysql_user_bob_%
    Function: mysql_user.present
        Name: bob
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.612142
    Duration: 1.148 ms
     Changes:
----------
          ID: mysql_user_bob_%_0
    Function: mysql_grants.present
        Name: bob_`foo\_%%`_all
      Result: False
     Comment: One or more requisite failed: mysql.user.mysql_user_bob_%
     Started: 16:13:54.613560
    Duration: 0.002 ms
     Changes:
----------
          ID: mysql_user_bob_%_1
    Function: mysql_grants.present
        Name: bob_bar_foobar
      Result: False
     Comment: One or more requisite failed: mysql.user.mysql_user_bob_%
     Started: 16:13:54.613679
    Duration: 0.002 ms
     Changes:
----------
          ID: mysql_user_alice_localhost
    Function: mysql_user.present
        Name: alice
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.613892
    Duration: 1.178 ms
     Changes:
----------
          ID: mysql_user_nopassuser_localhost
    Function: mysql_user.present
        Name: nopassuser
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.615291
    Duration: 1.248 ms
     Changes:
----------
          ID: mysql_user_obsoleteuser_localhost
    Function: mysql_user.absent
        Name: obsoleteuser
      Result: False
     Comment: MySQL Error 1698: Access denied for user 'salt'@'localhost'
     Started: 16:13:54.616702
    Duration: 1.125 ms
     Changes:

Summary for salt-minion-2
-------------
Succeeded:  8 (changed=2)
Failed:    20
-------------
Total states run:     28
Total run time:    5.012 s
ERROR: Minions returned with non-zero exit code