Reputation: 134
I tried something like this snippet below, but the second task gets executed on the host's shell terminal, rather than the mysql shell. How do i execute commands on the opened mysqlsh in the first task? Eg: i want to login to the shell and check the status of the mysql cluster.
tasks:
- name: "connect as clusteradmin"
shell: mysqlsh --uri admin@host1 -p'pass'
- name: "get cluster"
shell: var cluster=dba.getCluster('cluster')
- name: "check status of cluster"
shell: cluster.status()
register: Clustersts
Upvotes: 0
Views: 933
Reputation: 26
try to put your request into one line with parameter '--execute=command'. Here is something which works for me:
mysqlsh -uUSER -pPASSWORD -P 3306 --execute='util.checkForServerUpgrade()'
Yours could look like as follows:
- name: "connect as clusteradmin and get cluster"
shell: mysqlsh --uri admin@host1 -p'pass' --execute='var cluster=dba.getCluster('cluster')'
and then:
- name: "connect as clusteradmin and check status of cluster"
shell: mysqlsh --uri admin@host1 -p'pass' --execute='cluster.status()'
Upvotes: 1