<commit_before>---
#
# Keystone tasks for browbeat
# * Change eventlet worker count or httpd process count
# * Change keystone deployed in eventlet or httpd
# * Change keystone in httpd thread count
#

- name: Determine if keystone is deployed in eventlet
  shell: ps afx | grep "[Kk]eystone-all" -c
  register: deployed
  when: "'not_defined' in '{{ keystone_deployment }}'"
  ignore_errors: true

- name: Set keystone_deployment variable to httpd
  set_fact: keystone_deployment='httpd'
  when: "'not_defined' in '{{ keystone_deployment }}' and deployed.stdout|int == 0"

- name: Set keystone_deployment variable to eventlet
  set_fact: keystone_deployment='eventlet'
  when: "'not_defined' in '{{ keystone_deployment }}'"

- name: Get keystone admin ip address
  command: crudini --get /etc/keystone/keystone.conf DEFAULT admin_bind_host
  register: admin_ip_addr

- name: Get keystone admin ip address
  command: crudini --get /etc/keystone/keystone.conf DEFAULT public_bind_host
  register: public_ip_addr

- name: Unmanage Keystone Service from pacemaker
  shell: pcs resource unmanage openstack-keystone

- name: Unmanage httpd Service from pacemaker
  shell: pcs resource unmanage httpd

- name: Stop Keystone Service
  service: name=openstack-keystone state=stopped

- name: Stop httpd services
  service: name=httpd state=stopped

- name: Configure eventlet workers
  ini_file:
    dest: /etc/keystone/keystone.conf
    mode: 0640
    section: "{{ item.section }}"
    option: "{{ item.option }}"
    value: "{{ item.value }}"
    backup: yes
  with_items:
    - { section: DEFAULT, option: verbose, value: False }
    - { section: DEFAULT, option: debug, value: False }
    - { section: DEFAULT, option: public_workers, value: "{{ workers }}" }
    - { section: DEFAULT, option: admin_workers, value: "{{ workers }}" }
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Unconfigure keystone in httpd if eventlet
  file:
    path: /etc/httpd/conf.d/10-keystone_wsgi_{{ item }}.conf
    state: absent
  with_items:
    - admin
    - main
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Create keystone in httpd wsgi directory
  file: 
    path: /var/www/cgi-bin/keystone
    state: directory
    owner: keystone
    group: keystone
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Copy Keystone in httpd files over
  copy:
    src: keystone_httpd
    dest: /var/www/cgi-bin/keystone/{{ item }}
    owner: keystone
    group: keystone
    mode: 0744
  with_items:
    - admin
    - main
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Configure httpd processes/threads
  template:
    src=keystone_wsgi.conf.j2
    dest=/etc/httpd/conf.d/10-keystone_wsgi_{{ item.interface }}.conf
    owner=root
    group=root
    mode=0644
  with_items:
    - ip_address: "{{ admin_ip_addr.stdout }}"
      interface: "admin"
      processes: "{{ workers }}"
      port: 35357
      threads: "{{ threads }}"
    - ip_address: "{{ public_ip_addr.stdout }}"
      interface: "main"
      processes: "{{ workers }}"
      port: 5000
      threads: "{{ threads }}"
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Configure httpd ports.conf for keystone
  template:
    src=keystone_ports.conf.j2
    dest=/etc/httpd/conf/ports.conf
    owner=root
    group=root
    mode=0644
  with_items:
    - admin_ip_address: "{{ admin_ip_addr.stdout }}"
      public_ip_address: "{{ public_ip_addr.stdout }}"
      deployment: "{{ keystone_deployment }}"

- name: Start Keystone services
  service: name=openstack-keystone state=started
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Start httpd services
  service: name=httpd state=started

- name: Manage Keystone Service from pacemaker
  shell: pcs resource manage openstack-keystone
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Manage httpd Service from pacemaker
  shell: pcs resource manage openstack-keystone<commit_msg>Cleaned up keystone adjustment.<commit_after>---
#
# Keystone tasks for browbeat
# * Change eventlet worker count or httpd process/thread count
# * Change keystone deployed in eventlet or httpd
#

- name: Determine if keystone is deployed in eventlet
  shell: ps afx | grep "[Kk]eystone-all" -c
  register: deployed
  when: "'not_defined' in '{{ keystone_deployment }}'"
  ignore_errors: true
  changed_when: false

- name: Set keystone_deployment variable/fact to httpd
  set_fact: keystone_deployment='httpd'
  when: "'not_defined' in '{{ keystone_deployment }}' and deployed.stdout|int == 0"

- name: Set keystone_deployment variable/fact to eventlet
  set_fact: keystone_deployment='eventlet'
  when: "'not_defined' in '{{ keystone_deployment }}'"

- name: Get keystone admin ip address
  command: crudini --get /etc/keystone/keystone.conf DEFAULT admin_bind_host
  register: admin_ip_addr
  changed_when: false

- name: Get keystone public ip address
  command: crudini --get /etc/keystone/keystone.conf DEFAULT public_bind_host
  register: public_ip_addr
  changed_when: false

#
# Configure keystone eventlet/httpd
#

- name: Configure eventlet workers
  ini_file:
    dest: /etc/keystone/keystone.conf
    mode: 0640
    section: "{{ item.section }}"
    option: "{{ item.option }}"
    value: "{{ item.value }}"
    backup: yes
  with_items:
    - { section: DEFAULT, option: verbose, value: False }
    - { section: DEFAULT, option: debug, value: False }
    - { section: DEFAULT, option: public_workers, value: "{{ workers }}" }
    - { section: DEFAULT, option: admin_workers, value: "{{ workers }}" }
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Unconfigure keystone in httpd if eventlet
  file:
    path: /etc/httpd/conf.d/10-keystone_wsgi_{{ item }}.conf
    state: absent
  with_items:
    - admin
    - main
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Create keystone in httpd wsgi directory
  file: 
    path: /var/www/cgi-bin/keystone
    state: directory
    owner: keystone
    group: keystone
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Copy keystone in httpd files over
  copy:
    src: keystone_httpd
    dest: /var/www/cgi-bin/keystone/{{ item }}
    owner: keystone
    group: keystone
    mode: 0744
  with_items:
    - admin
    - main
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Configure httpd processes/threads
  template:
    src=keystone_wsgi.conf.j2
    dest=/etc/httpd/conf.d/10-keystone_wsgi_{{ item.interface }}.conf
    owner=root
    group=root
    mode=0644
  with_items:
    - ip_address: "{{ admin_ip_addr.stdout }}"
      interface: "admin"
      processes: "{{ workers }}"
      port: 35357
      threads: "{{ threads }}"
    - ip_address: "{{ public_ip_addr.stdout }}"
      interface: "main"
      processes: "{{ workers }}"
      port: 5000
      threads: "{{ threads }}"
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Configure/Unconfigure httpd ports.conf for keystone
  template:
    src=keystone_ports.conf.j2
    dest=/etc/httpd/conf/ports.conf
    owner=root
    group=root
    mode=0644
  with_items:
    - admin_ip_address: "{{ admin_ip_addr.stdout }}"
      public_ip_address: "{{ public_ip_addr.stdout }}"
      deployment: "{{ keystone_deployment }}"

#
# Umanage all services from pacemaker, stop keystone eventlet and restart
# httpd for keystone in httpd
#

- name: Set pacemaker default to unmanaged for httpd
  command: pcs property set is-managed-default=false
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Stop keystone service
  service: name=openstack-keystone state=stopped
  when: "'httpd' in '{{ keystone_deployment }}'"

- name: Restart httpd service
  service: name=httpd state=restarted
  when: "'httpd' in '{{ keystone_deployment }}'"

#
# Restart and manage keystone/httpd correctly for keystone in eventlet
#

- name: Unmanage keystone service from pacemaker
  command: pcs resource unmanage openstack-keystone
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Unmanage httpd service from pacemaker
  command: pcs resource unmanage httpd
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Restart httpd service
  service: name=httpd state=restarted
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Restart keystone service
  service: name=openstack-keystone state=restarted
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Manage keystone service from pacemaker
  command: pcs resource manage openstack-keystone
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Manage httpd service from pacemaker
  command: pcs resource manage httpd
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Set pacemaker default to managed for eventlet
  command: pcs property set is-managed-default=true
  when: "'eventlet' in '{{ keystone_deployment }}'"

- name: Cleanup keystone service in pacemaker
  command: pcs resource cleanup openstack-keystone
  when: "'eventlet' in '{{ keystone_deployment }}'"
{'fraction_non_alphanumeric': 0.11767992847563702, 'fraction_numerical': 0.007152436298614216, 'mean_word_length': 3.712480252764613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3305078', 'n_tokens_mistral': 3150, 'n_tokens_neox': 2913, 'n_words': 806}