如果我在Linux终端中运行这个cmd mysql_secure_installation,它将请求用户输入(y/n/其他选项)。如何在一本不可信的剧本中反映同样的情况?我尝试为这个cmd mysql_secure_installation使用shell模块,但不确定如何为用户输入编写,如下所示。
我的任务是使用Ansible Playbook安装MysqlDB。此外,我还附上了MYSQL安装的手动步骤。请帮我写一本同样的游戏手册。
提前谢谢。
#############################################################
Press y|Y for Yes, any other key for No: y
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Please set the password for root here.
New password: <my-password>
Re-enter new password: <my-password>
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
#############################################################
MYSQL Installation:--
sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm
sudo yum install -y mysql-server
sudo systemctl status mysqld
sudo systemctl start mysqld
mysql_secure_installation
.....
mysql -u root -p
Enter password: <my-password>
GRANT ALL ON root.* TO root@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
sudo systemctl restart mysqld
sudo systemctl status mysqld
-------------------------------------------------------------------------------------------------------------发布于 2021-04-14 07:20:12
是的,您可以检查角色是否存在,但是您也有已经存在的模块:
安装oracle的示例
- name: Install Oracle MySQL repo for RedHat Family.
yum:
name: "{{ redhat_mysql_repo }}"
state: present
when: ansible_os_family == "RedHat" and 'mysql' in group_names另一个样本:
- name: Initialize MySQL 8.0 Insecure.
shell: >
mysqld --initialize-insecure
when: ('8.0.' in mysql_cli_version.stdout) and (ansible_os_family == "RedHat")你可以在8上看到这个例子
https://stackoverflow.com/questions/67072854
复制相似问题