Created
          November 18, 2019 10:21 
        
      - 
      
- 
        Save ebuildy/3395dcabc02052449163d27e129d135c to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | apiVersion: batch/v1 | |
| kind: Job | |
| metadata: | |
| name: {{ stack_name }}-security-setup-users | |
| spec: | |
| template: | |
| spec: | |
| containers: | |
| - name: update-credentials | |
| image: radial/busyboxplus | |
| command: ["/bin/sh", "-c"] | |
| args: | |
| {% for user in global.security.users %} | |
| {%- if user.to_setup -%} | |
| - "curl -s -u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD} -H 'Content-Type: application/json' ${ELASTICSEARCH_URL}/_security/user/{{ user.name }}/_password --data \"{\\\"password\\\" : \\\"{{ user.password }}\\\"}\"" | |
| {%- endif -%} | |
| {%- endfor %} | |
| env: | |
| - name: ELASTICSEARCH_URL | |
| value: "http://{{ elasticsearch.clusterName }}-{{ elasticsearch.clientNodeGroup }}:9200" | |
| {% for user in global.security.users %} | |
| - name: {{ user.name | upper }}_USERNAME | |
| valueFrom: | |
| secretKeyRef: | |
| name: {{ stack_name }}-{{ user.name }}-credentials | |
| key: username | |
| - name: {{ user.name | upper }}_PASSWORD | |
| valueFrom: | |
| secretKeyRef: | |
| name: {{ stack_name }}-{{ user.name }}-credentials | |
| key: password | |
| {% endfor %} | |
| restartPolicy: Never | |
| backoffLimit: 4 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment