私はAnsibleで複製を行いたいです。グローバル変数に変換するには?
しかし、このコードは、エラーを返します:
- name: Semi-synchronous - Get the master status
mysql_replication: mode=getmaster
register: binlog
when: hostname.stdout.find('usme-db-master') == 0
- name: Debug
debug: var=binlog.File
when: hostname.stdout.find('usme-db-slave') == 0
は出力:
ASK [dbtier : Semi-synchronous - Get the master status] ***********************
skipping: [192.168.30.6] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}
ok: [192.168.30.5 -> 192.168.30.5] => {"Binlog_Do_DB": "", "Binlog_Ignore_DB": "", "Executed_Gtid_Set": "", "File": "usme-db-master-bin.000033", "Is_Master": true, "Position": 154, "changed": false}
TASK [dbtier : Debug] **********************************************************
skipping: [192.168.30.5] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}
ok: [192.168.30.6] => {
"binlog.File": "VARIABLE IS NOT DEFINED!"
}
TASKマスターを取得し、ファイルと位置を取得することです。
しかし、次のタスクは、"binlog.File": "VARIABLE IS NOT DEFINED!"
はたぶんAnsibleがusme-db-master
とusme-db-slave
区別であると言います。
どうすればよいですか?
バージョンは2.3.0
使用{{}}変数を使用しています。だからvar = "{{binlog.File}}" – Shasha99
@ Shasha99いいえ、それは正しい構文ではありません。 OPの使用は正しいです。 – techraf