1. Ad-HOC: 适合临时执行任务 2. Playbook: 适合一些复杂的部署和配置环境 一、 Ad-HOC: 适合临时执行任务 ansible-doc -l 查看ansible的可用模块 1.pnig 检查是否能联通 2.yum 选项:name 安装包名字 state 可以写一些安装或者卸载的命令 例子ansible webservers -m yum -a 'name=httpd state=latest/absent...
ansible-playbook test1.yaml --syntax-check #检查yaml文件的语法是否正确 ansible-playbook test1.yaml --list-task #检查tasks任务 ansible-playbook test1.yaml --list-hosts #检查生效的主机 ansible-playbook test1.yaml --start-at-task='install httpd' #指定从某个task开始运行 1. 2. 3. 4. 5. 6...
mariadb-name:grantslaveusershell:mysql-e"GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'demo_pass'"when:mysql_role=="master"-name:masterbinlognameshell:"mysql -e \"show master status\\G;\" | grep File | awk -F: '{print $2}' | awk '{gsub(/^\\s+|\\s+...
MYSQLBIN=$(/usr/local/mysql/bin/mysql -u ${REPLUSER} -p${REPLPASS} -h${MYSQL_MASTER} -e "show master status\G;"|egrep 'File: .*+'|awk '{print $2}') BINPOSITION=$(/usr/local/mysql/bin/mysql -uroot -p${MYSQL_PASS} -e "show master status\G;"|egrep 'Position: .*+'|aw...
使用ansible-playbook 编写安装脚本 yaml 注意事项 自定义主机操作列表 hosts 文件 [mariadb_hosts] 192.168.114.133 server_id='1' mysql_role=master 192.168.114.134 server_id='2' mysql_role=salve 192.168.114.135 server_id='3' mysql_role=salve ...
在Ansible中运行MySQL查询可以通过使用Ansible的mysql_db模块来实现。mysql_db模块是Ansible的一个核心模块,用于执行MySQL数据库操作。 下面是一个示例的Ansible playbook,演示了如何在Ansible中运行MySQL查询: 代码语言:txt 复制 - name: Run MySQL query hosts: your_mysql_host tasks: - name: Execute MySQL query...
install.yml install_mysql.sh my.cnf mysql_security.sh 3、roles安装步骤: 下载roles包:https://pan.baidu.com/s/18RETLv_ESy3m7zwrz7N-uQ 执行: ansible-playbook /你的路径/mysql_install.yml --extra-vars "host=你的主机群组 user=root"
├── mysql.yml 整个工程托管在github https://github.com/huangmeng4520/palybook_mysql5.7.git 执行ansible过程演示 root@afb8d4a179be:/# ansible-playbook/opt/playbook/roles/mysql.yml-vv Using/etc/ansible/ansible.cfgasconfig file statically included:/opt/playbook/roles/mysql_install/tasks/copy.yml ...
ansible-playbook mysql_query.yml 运行playbook 后,可看到类似于以下结果的输出: JSON 复制 "servers": [ { "admin_username": "mysqladmin", "enforce_ssl": false, "fully_qualified_domain_name": "mysqlserveransible.mysql.database.azure.com", "id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d...
ansible-playbook mysql_query.yml 运行playbook 后,可看到类似于以下结果的输出: JSON 复制 "servers": [ { "admin_username": "mysqladmin", "enforce_ssl": false, "fully_qualified_domain_name": "mysqlserveransible.mysql.database.azure.com", "id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d...