<commit_before>#
#  DO NOT ADD mysql OR mongo server ROLES TO THIS PLAYBOOK
#  THIS PLAYBOOK MUST REMAIN COMPATIBLE WITH EXTERNAL DB SERVERS
#
- hosts: cas-servers
  vars:
    webserver_nginx: true
  serial:
  - 1
  - "100%"
  tasks:
  - include_role:
      name: common
  - apt:
      name: "{{ packages }}"
    vars:
      packages:
      - mysql-client
      - python-mysqldb
      - python-pymongo
  - include_role:
      name: postfix
  - include_role:
      name: webserver
  - copy:
      src: "{{ cas_db_dump }}"
      dest: /tmp/cas.sql
    when: cas_db_dump is defined
  - copy:
      src: "{{ apikey_db_dump }}"
      dest: /tmp/apikey.sql
    when: apikey_db_dump is defined
  - mysql_db:
      state: absent
      name: "{{ cas_db_name | default('emmet') }}"
      login_host: "{{ cas_db_hostname }}"
      login_port: "{{ cas_db_port | default('3306') }}"
      login_user: "{{ mysql_root_username }}"
      login_password: "{{ <PASSWORD> }}"
    when: cas_db_dump is defined
    run_once: true
  - mysql_db:
      state: import
      name: "{{ cas_db_name | default('emmet') }}"
      target: /tmp/cas.sql
      login_host: "{{ cas_db_hostname }}"
      login_port: "{{ cas_db_port | default('3306') }}"
      login_user: "{{ mysql_root_username }}"
      login_password: "{{ <PASSWORD> }}"
    when: cas_db_dump is defined
    run_once: true
  - mysql_db:
      state: import
      name: "{{ apikey_db_name | default('apikey') }}"
      target: /tmp/apikey.sql
      login_host: "{{ apikey_db_hostname }}"
      login_port: "{{ apikey_db_port | default('3306') }}"
      login_user: "{{ mysql_root_username }}"
      login_password: "{{ <PASSWORD> }}"
    when: apikey_db_dump is defined
    run_once: true
  - mysql_db:
      state: present
      name: "{{ item.name }}"
      login_host: "{{ item.login_host }}"
      login_port: "{{ item.login_port }}"
      login_user: "{{ item.login_user }}"
      login_password: "{{ item.login_password }}"
      encoding: "{{ cas_db_encoding | default('utf8') }}"
    run_once: true
    with_items:
    - { name: "{{ cas_db_name | default('emmet') }}", login_host: "{{ cas_db_hostname }}", login_port: "{{ cas_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
    - { name: "{{ apikey_db_name | default('apikey') }}", login_host: "{{ apikey_db_hostname }}", login_port: "{{ apikey_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
  # Need the external ipv4 address for mysql user when using external databse, otherwise localhost
  - set_fact:
      cas_mysql_src_host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
    when:
      cas_db_hostname != 'localhost'
  - set_fact:
      cas_mysql_src_host: localhost
    when:
      cas_db_hostname == 'localhost'
  - set_fact:
      apikey_mysql_src_host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
    when:
      apikey_db_hostname != 'localhost'
  - set_fact:
      apikey_mysql_src_host: localhost
    when:
      apikey_db_hostname == 'localhost'
  - mysql_user:
      login_host: "{{ item.login_host }}"
      login_port: "{{ item.login_port }}"
      login_user: "{{ item.login_user }}"
      login_password: "{{ item.login_password }}"
      user: "{{ item.user }}"
      password: "{{ <PASSWORD> }}"
      priv: "{{ item.priv }}"
      host: "{{ item.host }}"
    with_items:
    - { user: "{{ cas_flyway_username }}", password: "{{ <PASSWORD> }}", priv: "{{ cas_db_name | default('emmet') }}.*:ALL", host: "{{ cas_mysql_src_host }}", login_host: "{{ cas_db_hostname }}", login_port: "{{ cas_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
    - { user: "{{ cas_db_username }}", password: "{{ <PASSWORD> }}", priv: "{{ cas_db_name | default('emmet') }}.*:INSERT,SELECT,UPDATE,DELETE,EXECUTE,TRIGGER/mysql.proc:SELECT", host: "{{ cas_mysql_src_host }}", login_host: "{{ cas_db_hostname }}", login_port: "{{ cas_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
    - { user: "{{ apikey_db_username }}", password: "{{ <PASSWORD>key_db_password }}", priv: "{{ apikey_db_name | default('apikey') }}.*:ALL", host: "{{ apikey_mysql_src_host }}", login_host: "{{ apikey_db_hostname }}", login_port: "{{ apikey_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
  - debug:
      msg: "Should be the mongo users created? {{ cas_add_mongo_users | default(False) }}"
  - mongodb_user:
      user: "{{ item.user }}"
      password: "{{ item.password }}"
      database: "{{ item.database }}"
      roles: "{{ item.roles }}"
      replica_set: "{{ item.replica_set }}"
      ssl: "{{ item.ssl }}"
      state: present
      login_host: "{{ item.login_host }}"
      login_port: "{{ item.login_port }}"
      login_database: "{{ item.login_database }}"
      login_user: "{{ item.login_user }}"
      login_password: "{{ item.login_password }}"
    with_items:
    - {
      login_host: "{{ cas_tickets_host }}",
      login_port: "{{ cas_tickets_port | default('27017') }}",
      login_user: "{{ mongodb_root_username }}",
      login_password: "{{ <PASSWORD>root_password }}",
      login_database: "{{ mongodb_root_database | default('admin') }}",
      user: "{{ cas_tickets_username }}",
      password: "{{ <PASSWORD> }}",
      database: "{{ cas_tickets_db | default('cas-ticket-registry') }}",
      replica_set: "{{ cas_tickets_replica_set | default('') }}",
      ssl: "{{ cas_tickets_ssl_enabled | default('false') }}",
      roles: 'readWrite' 
    }
    - {
      login_host: "{{ cas_services_host }}",
      login_port: "{{ cas_services_port | default('27017') }}",
      login_user: "{{ mongodb_root_username }}",
      login_password: "{{ <PASSWORD> }}",
      login_database: "{{ mongodb_root_database | default('admin') }}",
      user: "{{ cas_services_username }}",
      password: "{{ <PASSWORD> }}",
      database: "{{ cas_services_db | default('cas-service-registry' ) }}",
      replica_set: "{{ cas_services_replica_set | default('') }}",
      ssl: "{{ cas_services_ssl_enabled | default('false') }}",
      roles: 'readWrite' 
    }
    - {
      login_host: "{{ cas_audit_host | default('localhost') }}",
      login_port: "{{ cas_audit_port | default('27017') }}",
      login_user: "{{ mongodb_root_username }}",
      login_password: "{{ <PASSWORD> }}",
      login_database: "{{ mongodb_root_database | default('admin') }}",
      user: "{{ cas_audit_username | default('cas') }}",
      password: "{{ <PASSWORD>_<PASSWORD>_password | default('password') }}",
      database: "{{ cas_audit_db | default('cas-audit-repository') }}",
      replica_set: "{{ cas_audit_replica_set | default('') }}",
      ssl: "{{ cas_audit_ssl_enabled | default('false') }}",
      roles: 'readWrite' 
    }
    tags: mongodb-org
    run_once: true
    when: cas_add_mongo_users is defined and cas_add_mongo_users
  - include_role:
      name: cas5
    vars:
      min_memory: "{{ cas_min_memory | default('512m') }}"
      max_memory: "{{ cas_max_memory | default('2g') }}"
      service_registry_init_from_json: '{{ inventory_hostname == ansible_play_batch[0] }}'
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: cas-management
    vars:
      min_memory: "{{ cas_management_min_memory | default('256m') }}"
      max_memory: "{{ cas_management_max_memory | default('1g') }}"
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: userdetails
    vars:
      min_memory: "{{ userdetails_min_memory | default('256m') }}"
      max_memory: "{{ userdetails_max_memory | default('1g') }}"
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: apikey
    vars:
      min_memory: "{{ apikey_min_memory | default('256m') }}"
      max_memory: "{{ apikey_max_memory | default('1g') }}"
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: nginx_vhost
    vars:
      hostname: "{{ cas_host_name }}"
      context_path: "{{ item.context }}"
      nginx_paths:
      - path: "/{{ item.context }}"
        is_proxy: true
        proxy_pass: "http://127.0.0.1:{{item.port}}/{{ item.context }}"
    with_items:
    - { appname: "cas", context: "{{ cas_context_path | default('cas') }}", port: "{{ cas_port | default('9000') }}" }
    - { appname: "cas-management", context: "{{ cas_management_context_path | default('cas-management') }}", port: "{{ cas_management_port | default('8070') }}" }
    - { appname: "userdetails", context: "{{ userdetails_context_path | default('userdetails') }}", port: "{{ userdetails_port | default('9001') }}" }
    - { appname: "apikey", context: "{{ apikey_context_path | default('apikey') }}", port: "{{ apikey_port | default('9002') }}" }
<commit_msg>Added missing appname in cas playbook<commit_after>#
#  DO NOT ADD mysql OR mongo server ROLES TO THIS PLAYBOOK
#  THIS PLAYBOOK MUST REMAIN COMPATIBLE WITH EXTERNAL DB SERVERS
#
- hosts: cas-servers
  vars:
    webserver_nginx: true
  serial:
  - 1
  - "100%"
  tasks:
  - include_role:
      name: common
  - apt:
      name: "{{ packages }}"
    vars:
      packages:
      - mysql-client
      - python-mysqldb
      - python-pymongo
  - include_role:
      name: postfix
  - include_role:
      name: webserver
  - copy:
      src: "{{ cas_db_dump }}"
      dest: /tmp/cas.sql
    when: cas_db_dump is defined
  - copy:
      src: "{{ apikey_db_dump }}"
      dest: /tmp/apikey.sql
    when: apikey_db_dump is defined
  - mysql_db:
      state: absent
      name: "{{ cas_db_name | default('emmet') }}"
      login_host: "{{ cas_db_hostname }}"
      login_port: "{{ cas_db_port | default('3306') }}"
      login_user: "{{ mysql_root_username }}"
      login_password: "{{ <PASSWORD> }}"
    when: cas_db_dump is defined
    run_once: true
  - mysql_db:
      state: import
      name: "{{ cas_db_name | default('emmet') }}"
      target: /tmp/cas.sql
      login_host: "{{ cas_db_hostname }}"
      login_port: "{{ cas_db_port | default('3306') }}"
      login_user: "{{ mysql_root_username }}"
      login_password: "{{ <PASSWORD> }}"
    when: cas_db_dump is defined
    run_once: true
  - mysql_db:
      state: import
      name: "{{ apikey_db_name | default('apikey') }}"
      target: /tmp/apikey.sql
      login_host: "{{ apikey_db_hostname }}"
      login_port: "{{ apikey_db_port | default('3306') }}"
      login_user: "{{ mysql_root_username }}"
      login_password: "{{ <PASSWORD> }}"
    when: apikey_db_dump is defined
    run_once: true
  - mysql_db:
      state: present
      name: "{{ item.name }}"
      login_host: "{{ item.login_host }}"
      login_port: "{{ item.login_port }}"
      login_user: "{{ item.login_user }}"
      login_password: "{{ <PASSWORD> }}"
      encoding: "{{ cas_db_encoding | default('utf8') }}"
    run_once: true
    with_items:
    - { name: "{{ cas_db_name | default('emmet') }}", login_host: "{{ cas_db_hostname }}", login_port: "{{ cas_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
    - { name: "{{ apikey_db_name | default('apikey') }}", login_host: "{{ apikey_db_hostname }}", login_port: "{{ apikey_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
  # Need the external ipv4 address for mysql user when using external databse, otherwise localhost
  - set_fact:
      cas_mysql_src_host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
    when:
      cas_db_hostname != 'localhost'
  - set_fact:
      cas_mysql_src_host: localhost
    when:
      cas_db_hostname == 'localhost'
  - set_fact:
      apikey_mysql_src_host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
    when:
      apikey_db_hostname != 'localhost'
  - set_fact:
      apikey_mysql_src_host: localhost
    when:
      apikey_db_hostname == 'localhost'
  - mysql_user:
      login_host: "{{ item.login_host }}"
      login_port: "{{ item.login_port }}"
      login_user: "{{ item.login_user }}"
      login_password: "{{ item.login_password }}"
      user: "{{ item.user }}"
      password: "{{ <PASSWORD> }}"
      priv: "{{ item.priv }}"
      host: "{{ item.host }}"
    with_items:
    - { user: "{{ cas_flyway_username }}", password: "{{ <PASSWORD> }}", priv: "{{ cas_db_name | default('emmet') }}.*:ALL", host: "{{ cas_mysql_src_host }}", login_host: "{{ cas_db_hostname }}", login_port: "{{ cas_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
    - { user: "{{ cas_db_username }}", password: "{{ <PASSWORD> }}", priv: "{{ cas_db_name | default('emmet') }}.*:INSERT,SELECT,UPDATE,DELETE,EXECUTE,TRIGGER/mysql.proc:SELECT", host: "{{ cas_mysql_src_host }}", login_host: "{{ cas_db_hostname }}", login_port: "{{ cas_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
    - { user: "{{ apikey_db_username }}", password: "{{ <PASSWORD> }}", priv: "{{ apikey_db_name | default('apikey') }}.*:ALL", host: "{{ apikey_mysql_src_host }}", login_host: "{{ apikey_db_hostname }}", login_port: "{{ apikey_db_port | default('3306') }}", login_user: "{{ mysql_root_username }}", login_password: "{{ <PASSWORD> }}" }
  - debug:
      msg: "Should be the mongo users created? {{ cas_add_mongo_users | default(False) }}"
  - mongodb_user:
      user: "{{ item.user }}"
      password: "{{ <PASSWORD> }}"
      database: "{{ item.database }}"
      roles: "{{ item.roles }}"
      replica_set: "{{ item.replica_set }}"
      ssl: "{{ item.ssl }}"
      state: present
      login_host: "{{ item.login_host }}"
      login_port: "{{ item.login_port }}"
      login_database: "{{ item.login_database }}"
      login_user: "{{ item.login_user }}"
      login_password: "{{ item.login_password }}"
    with_items:
    - {
      login_host: "{{ cas_tickets_host }}",
      login_port: "{{ cas_tickets_port | default('27017') }}",
      login_user: "{{ mongodb_root_username }}",
      login_password: "{{ <PASSWORD> }}",
      login_database: "{{ mongodb_root_database | default('admin') }}",
      user: "{{ cas_tickets_username }}",
      password: "{{ <PASSWORD> }}",
      database: "{{ cas_tickets_db | default('cas-ticket-registry') }}",
      replica_set: "{{ cas_tickets_replica_set | default('') }}",
      ssl: "{{ cas_tickets_ssl_enabled | default('false') }}",
      roles: 'readWrite' 
    }
    - {
      login_host: "{{ cas_services_host }}",
      login_port: "{{ cas_services_port | default('27017') }}",
      login_user: "{{ mongodb_root_username }}",
      login_password: "{{ <PASSWORD> }}",
      login_database: "{{ mongodb_root_database | default('admin') }}",
      user: "{{ cas_services_username }}",
      password: "{{ <PASSWORD> }}",
      database: "{{ cas_services_db | default('cas-service-registry' ) }}",
      replica_set: "{{ cas_services_replica_set | default('') }}",
      ssl: "{{ cas_services_ssl_enabled | default('false') }}",
      roles: 'readWrite' 
    }
    - {
      login_host: "{{ cas_audit_host | default('localhost') }}",
      login_port: "{{ cas_audit_port | default('27017') }}",
      login_user: "{{ mongodb_root_username }}",
      login_password: "{{ <PASSWORD> }}",
      login_database: "{{ mongodb_root_database | default('admin') }}",
      user: "{{ cas_audit_username | default('cas') }}",
      password: "{{ cas_audit_password | default('password') }}",
      database: "{{ cas_audit_db | default('cas-audit-repository') }}",
      replica_set: "{{ cas_audit_replica_set | default('') }}",
      ssl: "{{ cas_audit_ssl_enabled | default('false') }}",
      roles: 'readWrite' 
    }
    tags: mongodb-org
    run_once: true
    when: cas_add_mongo_users is defined and cas_add_mongo_users
  - include_role:
      name: cas5
    vars:
      min_memory: "{{ cas_min_memory | default('512m') }}"
      max_memory: "{{ cas_max_memory | default('2g') }}"
      service_registry_init_from_json: '{{ inventory_hostname == ansible_play_batch[0] }}'
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: cas-management
    vars:
      min_memory: "{{ cas_management_min_memory | default('256m') }}"
      max_memory: "{{ cas_management_max_memory | default('1g') }}"
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: userdetails
    vars:
      min_memory: "{{ userdetails_min_memory | default('256m') }}"
      max_memory: "{{ userdetails_max_memory | default('1g') }}"
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: apikey
    vars:
      min_memory: "{{ apikey_min_memory | default('256m') }}"
      max_memory: "{{ apikey_max_memory | default('1g') }}"
      bootadmin_client_base_url: 'https://{{ inventory_hostname}}/'
  - include_role:
      name: nginx_vhost
    vars:
      appname: "{{ item.appname }}"
      hostname: "{{ cas_host_name }}"
      context_path: "{{ item.context }}"
      nginx_paths:
      - path: "/{{ item.context }}"
        appname: "{{ item.appname }}"
        is_proxy: true
        proxy_pass: "http://127.0.0.1:{{item.port}}/{{ item.context }}"
    with_items:
    - { appname: "cas", context: "{{ cas_context_path | default('cas') }}", port: "{{ cas_port | default('9000') }}" }
    - { appname: "cas-management", context: "{{ cas_management_context_path | default('cas-management') }}", port: "{{ cas_management_port | default('8070') }}" }
    - { appname: "userdetails", context: "{{ userdetails_context_path | default('userdetails') }}", port: "{{ userdetails_port | default('9001') }}" }
    - { appname: "apikey", context: "{{ apikey_context_path | default('apikey') }}", port: "{{ apikey_port | default('9002') }}" }

{'fraction_non_alphanumeric': 0.17996904709263764, 'fraction_numerical': 0.010501879283661288, 'mean_word_length': 3.4740356083086055, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2602377', 'n_tokens_mistral': 6349, 'n_tokens_neox': 6270, 'n_words': 1053}