<commit_before>---
# This role installs openam
# This assumes tomcat has already been installed
# Assumes the software has been downloaded and is available at {{ forgerock_download_dir }}/openam
# Uses the variable {{ tomcat_openam_dir }} to know where to install the war file. 
#  This should be the path to the openam tomcat instance (/var/lib/tomcats/openam on Fedora)

- name: Clean up old install dirs in case this is a re-install
  file: path="{{download_dir}}/openam" state=absent

- file:  path="{{ install_root }}/ssoadmin" state=absent
- file:  path="{{ install_root }}/ssoconfigtool" state=absent
- service: name=tomcat@openam.service state=stopped
- file: path="{{ tomcat_openam_dir }}/webapps/openam"  state=absent 

  
- name: Check for staged OpenAM bits - so we can skip download
  stat: path=/vagrant/staging/{{openam_zip_file}}
  register: staged_openam
  
  # Copy staged openam dist bits
- name: Copy staged OpenAM bits to image
  command: cp /vagrant/staging/{{openam_zip_file}} {{download_dir}}
  when: staged_openam.stat.exists
  
- name: download openam
  get_url: url="{{openam_download_url}}" dest="{{download_dir}}/{{openam_zip_file}}"
  environment: proxy_env
  when: staged_openam.stat.exists == false
  
- name: Unpack downloaded OpenAM bits
  command: chdir={{download_dir}} unzip {{openam_zip_file}}

# create install dir, openam dir
- file: path={{ install_root}} owner={{ fr_user }} state="directory" 

# Note that the openam config dir has to be writable by the user who runs the web container
# In our case that is tomcat. TODO: Use group permissions here
- file: path={{ install_root}}/openam owner=tomcat state="directory" 


- name: unpack ssoadm tools
  command: creates={{ install_root }}/ssoadmin unzip {{ download_dir }}/openam/SSOAdminTools-{{ openam_version }}.zip -d {{ install_root }}/ssoadmin
- command: chmod 0755 {{ install_root }}/ssoadmin/setup

- name: unpack config tools
  command: creates="{{ install_root }}/ssoconfigtool" unzip {{ download_dir }}/openam/SSOConfiguratorTools-{{ openam_version }}.zip -d {{ install_root }}/ssoconfigtool
  
- name: copy config file
  template: src=openam.config dest={{ install_root }}/ssoconfigtool/openam.config owner={{fr_user}} mode=0644
 
# Assume we already have a tomcat instance
#- name: Create a tomcat instance for OpenAM
#  command: creates={{tomcat_openam_dir}} tomcat8-instance-create -p {{openam_server_port}} -c {{openam_control_port}} 
#           {{tomcat_openam_dir}} 
           
- name: Deploy war to tomcat
  command: creates="{{ tomcat_openam_dir }}/webapps/openam" cp {{ download_dir }}/openam/OpenAM-{{ openam_version }}.war {{ tomcat_openam_dir}}/webapps/openam.war
 
# Note: tomcat install already creates start files
#- name: Create systemd startup
#  template: src=openam.service dest=/etc/systemd/system 
#  
#- command: chown -R {{ fr_user }} {{ install_root}} 
#- command: systemctl --system daemon-reload 
#- command: systemctl enable openam.service
#- command: systemctl start openam.service

- name: Ensure openam tomcat instance is running
  service: name="<EMAIL>" state=restarted enabled=yes

- name: Wait for openam war to be fully deployed before running configurator
  wait_for: port={{openam_server_port}} delay=1

# Bit of hack. The previous command waits for the port -but AM could still be deploying
# So this waits another 30 seconds to be safe
- wait_for: port={{openam_server_port}} delay=30

  
#  name: Run openam configurator
#  command: creates={{install_root}}/openam/bootstrap java -jar {{ install_root }}/ssoconfigtool/openam-configurator-tool-{{ openam_version }}.jar 
#         --file {{ install_root }}/ssoconfigtool/openam.config --acceptLicense
         
  name: Run openam configurator
  command: creates={{install_root}}/openam/bootstrap java -jar {{ install_root }}/ssoconfigtool/openam-configurator-tool-{{ openam_version }}.jar 
         --file {{ install_root }}/ssoconfigtool/openam.config
 

# Create ssoadm tools - set JAVA_HOME=/usr/lib/jvm/java
- name: setup ssoadm tools
  command: chdir={{ install_root }}/ssoadmin {{ install_root }}/ssoadmin/setup -p {{ install_root }}/openam --acceptLicense
  environment:
    JAVA_HOME: "{{java_home}}"

# Make sure everything is owned by fr user  
- file: recurse=yes state=directory  owner="{{ fr_user }}" 
     group="tomcat" path="{{ install_root}}" mode=0775


# Optional tasks.... this should probably be a separate role / playbook 

#- name: copy policy.xml for import
#  copy: src=policy.xml dest=etc/policy.xml  mode=0622

# This is failing on the when we are not using example.com domain- find out why later
# probably because root policy.xml needs to be fixed
#- name: Import policy.xml
#  command: bin/import-policies etc/policy.xml
<commit_msg>changed --acceptLicense switch on OpenAM configurator command<commit_after>---
# This role installs openam
# This assumes tomcat has already been installed
# Assumes the software has been downloaded and is available at {{ forgerock_download_dir }}/openam
# Uses the variable {{ tomcat_openam_dir }} to know where to install the war file. 
#  This should be the path to the openam tomcat instance (/var/lib/tomcats/openam on Fedora)

- name: Clean up old install dirs in case this is a re-install
  file: path="{{download_dir}}/openam" state=absent

- file:  path="{{ install_root }}/ssoadmin" state=absent
- file:  path="{{ install_root }}/ssoconfigtool" state=absent
- service: name=<EMAIL> state=stopped
- file: path="{{ tomcat_openam_dir }}/webapps/openam"  state=absent 

  
- name: Check for staged OpenAM bits - so we can skip download
  stat: path=/vagrant/staging/{{openam_zip_file}}
  register: staged_openam
  
  # Copy staged openam dist bits
- name: Copy staged OpenAM bits to image
  command: cp /vagrant/staging/{{openam_zip_file}} {{download_dir}}
  when: staged_openam.stat.exists
  
- name: download openam
  get_url: url="{{openam_download_url}}" dest="{{download_dir}}/{{openam_zip_file}}"
  environment: proxy_env
  when: staged_openam.stat.exists == false
  
- name: Unpack downloaded OpenAM bits
  command: chdir={{download_dir}} unzip {{openam_zip_file}}

# create install dir, openam dir
- file: path={{ install_root}} owner={{ fr_user }} state="directory" 

# Note that the openam config dir has to be writable by the user who runs the web container
# In our case that is tomcat. TODO: Use group permissions here
- file: path={{ install_root}}/openam owner=tomcat state="directory" 


- name: unpack ssoadm tools
  command: creates={{ install_root }}/ssoadmin unzip {{ download_dir }}/openam/SSOAdminTools-{{ openam_version }}.zip -d {{ install_root }}/ssoadmin
- command: chmod 0755 {{ install_root }}/ssoadmin/setup

- name: unpack config tools
  command: creates="{{ install_root }}/ssoconfigtool" unzip {{ download_dir }}/openam/SSOConfiguratorTools-{{ openam_version }}.zip -d {{ install_root }}/ssoconfigtool
  
- name: copy config file
  template: src=openam.config dest={{ install_root }}/ssoconfigtool/openam.config owner={{fr_user}} mode=0644
 
# Assume we already have a tomcat instance
#- name: Create a tomcat instance for OpenAM
#  command: creates={{tomcat_openam_dir}} tomcat8-instance-create -p {{openam_server_port}} -c {{openam_control_port}} 
#           {{tomcat_openam_dir}} 
           
- name: Deploy war to tomcat
  command: creates="{{ tomcat_openam_dir }}/webapps/openam" cp {{ download_dir }}/openam/OpenAM-{{ openam_version }}.war {{ tomcat_openam_dir}}/webapps/openam.war
 
# Note: tomcat install already creates start files
#- name: Create systemd startup
#  template: src=openam.service dest=/etc/systemd/system 
#  
#- command: chown -R {{ fr_user }} {{ install_root}} 
#- command: systemctl --system daemon-reload 
#- command: systemctl enable openam.service
#- command: systemctl start openam.service

- name: Ensure openam tomcat instance is running
  service: name="<EMAIL>" state=restarted enabled=yes

- name: Wait for openam war to be fully deployed before running configurator
  wait_for: port={{openam_server_port}} delay=1

# Bit of hack. The previous command waits for the port -but AM could still be deploying
# So this waits another 30 seconds to be safe
- wait_for: port={{openam_server_port}} delay=30

  
#  - name: Run openam configurator
#  command: creates={{install_root}}/openam/bootstrap java -jar {{ install_root }}/ssoconfigtool/openam-configurator-tool-{{ openam_version }}.jar 
#         --file {{ install_root }}/ssoconfigtool/openam.config --acceptLicense
         
- name: Run openam configurator
  command: creates={{install_root}}/openam/bootstrap java -jar {{ install_root }}/ssoconfigtool/openam-configurator-tool-{{ openam_version }}.jar 
         --file {{ install_root }}/ssoconfigtool/openam.config
 

# Create ssoadm tools - set JAVA_HOME=/usr/lib/jvm/java
- name: setup ssoadm tools
  command: chdir={{ install_root }}/ssoadmin {{ install_root }}/ssoadmin/setup -p {{ install_root }}/openam --acceptLicense
  environment:
    JAVA_HOME: "{{java_home}}"

# Make sure everything is owned by fr user  
- file: recurse=yes state=directory  owner="{{ fr_user }}" 
     group="tomcat" path="{{ install_root}}" mode=0775


# Optional tasks.... this should probably be a separate role / playbook 

#- name: copy policy.xml for import
#  copy: src=policy.xml dest=etc/policy.xml  mode=0622

# This is failing on the when we are not using example.com domain- find out why later
# probably because root policy.xml needs to be fixed
#- name: Import policy.xml
#  command: bin/import-policies etc/policy.xml

{'fraction_non_alphanumeric': 0.11813992459153749, 'fraction_numerical': 0.004608294930875576, 'mean_word_length': 4.382750845546787, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2199879', 'n_tokens_mistral': 3078, 'n_tokens_neox': 2995, 'n_words': 944}