内容简介:saltstack在state.sls中创建数据库和用户名查看原有的数据库信息:
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | zabbix | +--------------------+ 4 rows in set (0.00 sec)state.sls文件:
[[email protected]_master base]# cat mysql_test.sls pkg_install: pkg.installed: - names: - MySQL-python - python-devel db_creat: mysql_database.present: - name: zabbix_test - connection_host: localhost - connection_user: root - connection_pass: qwe123 user_creat: mysql_user.present: - name: zabbix_test - host: localhost - password: zabbix_test - use: - mysql_database: db_creat user_grant: mysql_grants.present: - grant: all privileges - database: zabbix_test.* - user: zabbix_test - host: 'localhost' - use: - mysql_database: db_creat执行state.sls操作
[[email protected]_master base]# salt 'zabbix_server' state.sls mysql_test zabbix_server: ---------- ID: pkg_install Function: pkg.installed Name: python-devel Result: True Comment: Package python-devel is already installed Started: 10:56:50.251481 Duration: 397.42 ms Changes: ---------- ID: pkg_install Function: pkg.installed Name: MySQL-python Result: True Comment: Package MySQL-python is already installed Started: 10:56:50.649097 Duration: 0.522 ms Changes: ---------- ID: db_creat Function: mysql_database.present Name: zabbix_test Result: True Comment: The database zabbix_test has been created Started: 10:56:50.650729 Duration: 4.404 ms Changes: ---------- zabbix_test: Present ---------- ID: user_creat Function: mysql_user.present Name: zabbix_test Result: True Comment: The userhas been added Started: 10:56:50.655521 Duration: 7.29 ms Changes: ---------- zabbix_test: Present ---------- ID: user_grant Function: mysql_grants.present Result: True Comment: Grant all privileges on zabbix_test.* tohas been added Started: 10:56:50.663209 Duration: 6.603 ms Changes: ---------- user_grant: Present Summary for zabbix_server ------------ Succeeded: 5 (changed=3) Failed: 0 ------------ Total states run: 5 Total run time: 416.239 ms查看结果:_server ~]# mysql -uzabbix_test -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 35 Server version: 5.6.36 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | zabbix_test | +--------------------+ 2 rows in set (0.00 sec)
以上所述就是小编给大家介绍的《saltstack在state.sls中创建数据库和用户名》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 如果修改 git 已提交的用户邮箱和用户名
- 用户名(昵称)XSS浅析
- Git 免用户名密码访问代码库
- Sqlmap初体验,渗透拿到网站用户名密码
- Ajax邮箱、用户名唯一性验证实例代码
- OpenSSH 7.8 发布,修复了用户名枚举漏洞
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。