saltstack在state.sls中创建数据库和用户名

栏目: 数据库 · 发布时间: 6年前

内容简介: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中创建数据库和用户名》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

IT大败局

IT大败局

Merrill R.Chapman、周良忠 / 周良忠 / 电子工业出版社 / 2004-8-1 / 35.00

这是一本由作者亲身经历写就的MBA式教案。通过作者那专业人士的敏锐、活泼流畅的文笔和美国人特有的幽默,本书为我们剖析了IT界十个有代表性且影响深远的愚蠢败局。这十个败局涉及企业经营的十个主要方面,它们是:产业标准的魔力,“缩水”产品的阴霾,产品定位的泥潭,市场关系的教训,巨型企业的困惑,企业并购的陷阱,品牌战略的迷茫,技术导向的失衡,企业公关的真谛和科技虚幻的诱惑。 书中有许多鲜为人......一起来看看 《IT大败局》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具