Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions ansible-scylla-manager/tasks/add_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
echo $(sctool status|grep -q "Cluster: {{ item.cluster_name }} " && echo "present")
register: cluster_already_added

- name: Fetch alternator salted hash for "{{ item.username }}"
shell: |
cqlsh {{ item.host }} -u '{{ item.username }}' -p '{{ item.password }}' \
Comment thread
ManjotS marked this conversation as resolved.
{% if item.ssl is defined and item.ssl|bool %}--ssl{% endif %} \
-e "SELECT salted_hash FROM system.roles WHERE role = '{{ item.username }}';" \
| grep -E '^\s+\$' | tr -d ' '
register: alternator_salted_hash
Comment thread
ManjotS marked this conversation as resolved.
# Alternator creds are best-effort: TLS-only clusters, transient network/auth
# failures, or missing SELECT on system.roles must not abort the cluster add/update.
failed_when: false
# stdout is a credential-equivalent secret; keep it out of Ansible logs/-vvv output.
no_log: true
when:
- item.username is defined
- item.password is defined

- name: run sctool cluster add for "{{ item.cluster_name }}"
shell: |
sctool cluster add \
Expand All @@ -20,6 +36,14 @@
--username {{ item.username }} \
--password {{ item.password }} \
{% endif %}
{% if alternator_salted_hash is defined
and alternator_salted_hash.stdout is defined
and alternator_salted_hash.stdout != '' %}
--alternator-access-key-id {{ item.username }} \
--alternator-secret-access-key '{{ alternator_salted_hash.stdout }}' \
Comment thread
ManjotS marked this conversation as resolved.
{% endif %}
# Command line embeds username/password and the alternator secret; suppress logging.
no_log: true
when: cluster_already_added is not defined or cluster_already_added.stdout != "present"

- name: Enforce configuration for existing cluster "{{ item.cluster_name }}"
Expand All @@ -33,5 +57,13 @@
--username {{ item.username }} \
--password {{ item.password }} \
{% endif %}
{% if alternator_salted_hash is defined
and alternator_salted_hash.stdout is defined
and alternator_salted_hash.stdout != '' %}
--alternator-access-key-id {{ item.username }} \
--alternator-secret-access-key '{{ alternator_salted_hash.stdout }}' \
{% endif %}
# Command line embeds username/password and the alternator secret; suppress logging.
no_log: true
when: cluster_already_added is defined and cluster_already_added.stdout == "present"

Loading