Ensighten / ansible-module-cassandra

Ansible modules for managing Cassandra users and roles
MIT License
7 stars 14 forks source link

user creation error #2

Open mootezbessifi opened 6 years ago

mootezbessifi commented 6 years ago

Hi all,

first of all, thank you a lot for suck ansible module. i need to mention that you example is not working, when i tried to run it, an exception occurs with the following output:

ERROR! 'login_hosts' is not a valid attribute for a Block

The error appears to have been in '/home/centos/fcs-automation/roles/cassandra/tasks/user-mgt.yml': line 3, column 3, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be: - block: ^ here

So i read the library content and i tried to run it like following:


(sorry for mis-formatting the task) when i run the above, i got the following error:

fatal: [cass1 -> None]: FAILED! => {"changed": false, "failed": true, "msg": "unable to connect to ****, check login_user and login_password are correct. Exception message: ('Unable to connect to any servers', {'192.168.0.3': DriverException('ProtocolError returned from server while using explicitly set client protocol_version 2',)})"}

Any help on this ??

PS: cassandra username and password are working fine using direct cqlsh.

sadams commented 6 years ago

Regarding the example: I could only guess that the version of ansible you are using doesn't work with blocks in the same way.

As for the exception: it looks like lib is hard coding the protocol version for connecting to the cluster. i would recommend changing the protocol version to see if that fixes it: https://github.com/Ensighten/ansible-module-cassandra/blob/master/library/cassandra_grant.py#L252

mootezbessifi commented 6 years ago

thanks for your quick response @sadams . According to the ansible version i am working with is 2.3.1.0. and i have some other code working fine with block module.

According to the exception, which protocol version i need to use to run this successfully?

sadams commented 6 years ago

I don't know. Which version of C* are you using and what is the header on your cqlsh client repl when you successfully login? I would start there. The simplest change you could probably make would be to change https://github.com/Ensighten/ansible-module-cassandra/blob/master/library/cassandra_grant.py#L252 to accept the protocol version as a parameter (like login_host etc) but default it to '2'. Then you could just change them to see if it worked with 3+.

mootezbessifi commented 6 years ago

yes @sadams indeed, i changed the hard coded protocol version to 3 and it works fone for me, now i would like to run the task for only on host from the ansible group 'cassandra' (cassandra inventory group contains list of cassandra cluster nodes). when added the below code under cassandra_role module , it does not work:


run_once: true delegate_to: "{{ groups['cassandra'][0] }}"

it skips it and run the task in all cassandra hosts

did cassandra_role module missing some inheritance maybe ?

sadams commented 6 years ago

The module isn't that clever. delegate_to isn't passed to the modules. the module simply runs the cql commands on whichever machine it's pointed at. If you point the task at all the nodes in your cluster, it will run on each node. best idea is to run the cql against only 1 of your nodes and let cassandra propagate the change:

 - hosts: cassandra[0]