<commit_before>{% set openstack = pillar['openstack'] -%}
{% set conn = openstack['db']['connection'].items() -%}

{% for service in ['keystone','nova','neutron','glance','cinder'] %}

{{service}}-database:
  mysql_database.present:
    - name: {{ openstack[service]['db']['name'] }}
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}

{{service}}-database-user:
  mysql_user.present:
    - name: {{openstack[service]['db']['username']}}
    - password: {{openstack[service]['db']['password']}}
    - host: '%'
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}

{{service}}-database-localhost-user:
  mysql_user.present:
    - name: {{openstack[service]['db']['username']}}
    - password: {{openstack[service]['db']['username']}}
    - host: localhost
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}
    - watch:
        - mysql_user: {{service}}-database-user

{{service}}-database-grant:
  mysql_grants.present:
    - grant: all privileges
    - database: {{openstack[service]['db']['name']}}.*
    - user: {{openstack[service]['db']['username']}}
    - host: '%'
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}
    - require:
        - mysql_user: {{service}}-database-user
        - mysql_database: {{service}}-database

{{service}}-database-localhost-grant:
  mysql_grants.present:
    - grant: all privileges
    - database: {{openstack[service]['db']['name']}}.*
    - host: localhost
    - user: {{openstack[service]['db']['username']}}
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}
    - require:
        - mysql_user: {{service}}-database-localhost-user
        - mysql_database: {{service}}-database
    - watch:
        - mysql_grants: {{service}}-database-grant


{% endfor %}
<commit_msg>Remove now unnecessary localhost specific users<commit_after>{% set openstack = pillar['openstack'] -%}
{% set conn = openstack['db']['connection'].items() -%}

{% for service in ['keystone','nova','neutron','glance','cinder'] %}

{{service}}-database:
  mysql_database.present:
    - name: {{ openstack[service]['db']['name'] }}
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}

{{service}}-database-user:
  mysql_user.present:
    - name: {{openstack[service]['db']['username']}}
    - password: {{openstack[service]['db']['password']}}
    - host: '%'
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}

{{service}}-database-grant:
  mysql_grants.present:
    - grant: all privileges
    - database: {{openstack[service]['db']['name']}}.*
    - user: {{openstack[service]['db']['username']}}
    - host: '%'
    {% for p,v in conn %}
    - connection_{{p}}: {{v}}
    {% endfor %}
    - require:
        - mysql_user: {{service}}-database-user
        - mysql_database: {{service}}-database
{% endfor %}

{'fraction_non_alphanumeric': 0.23071577484364142, 'fraction_numerical': 0.0, 'mean_word_length': 3.355521936459909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7207570', 'n_tokens_mistral': 991, 'n_tokens_neox': 909, 'n_words': 167}