<commit_before>---

# TODO we could also write a module to do all steps for one app, and then go on for the second app and so on

#{
#  "django-async.local": "dns",
#  "clone_dir": "django_async", OR "github_url": "<EMAIL>:yorrick/django_async.git"
#  "wsgi_module": "django_async.wsgi_app_prod",
#  "venv": "django_async_venv",
#  "settings_module": "django_async.settings_prod",
#}

- name: Create deployer user
  user: name=deployer comment="deployer user" createhome=yes shell=/bin/bash

# TODO make it run once
- name: Add github ssh public key
  shell: ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts
  sudo: yes

# setup a bare repo that acts as a cache to avoid fetching whole apps for each deployement
# TODO setup a key for user deployer, and see if permissions are ok (maybe check with ACLs)
# then we'll be able to use ssh with deployer user
- name: Setup bare repo
# TODO find the repo name
  git: repo={{ item.github_url }} bare=yes dest={{ app_clone }}/django_async.git force=yes
  sudo: yes
#  sudo_user: deployer
  with_items:
    - "{{ deploy_apps }}"

- name: Create app dir
  file: dest={{ app_dir }}/{{ item.dns }} state=directory
  with_items:
    - "{{ deploy_apps }}"

# then setup a repo in {{ app_dir }}/{{ item.dns }}/clone that uses the bare repo as origin
# TODO find the repo name
- name: Clone app repo
  git: repo=file://{{ app_clone }}/django_async.git version=master dest={{ app_dir }}/{{ item.dns }}/clone<commit_msg>use jinja filters<commit_after>---

# TODO we could also write a module to do all steps for one app, and then go on for the second app and so on

#{
#  "django-async.local": "dns",
#  "clone_dir": "django_async", OR "github_url": "<EMAIL>:yorrick/django_async.git"
#  "wsgi_module": "django_async.wsgi_app_prod",
#  "venv": "django_async_venv",
#  "settings_module": "django_async.settings_prod",
#}

- name: Create deployer user
  user: name=deployer comment="deployer user" createhome=yes shell=/bin/bash

# TODO make it run once
- name: Add github ssh public key
  shell: ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts
  sudo: yes

# setup a bare repo that acts as a cache to avoid fetching whole apps for each deployement
# TODO setup a key for user deployer, and see if permissions are ok (maybe check with ACLs)
# then we'll be able to use ssh with deployer user
- name: Setup bare repo
  git: repo={{ item.github_url }} bare=yes dest={{ app_clone }}/{{ item.github_url | basename }} force=yes
  sudo: yes
#  sudo_user: deployer
  with_items:
    - "{{ deploy_apps }}"

- name: Create app dir
  file: dest={{ app_dir }}/{{ item.dns }} state=directory
  with_items:
    - "{{ deploy_apps }}"

# then setup a repo in {{ app_dir }}/{{ item.dns }}/clone that uses the bare repo as origin
- name: Clone app repo
  git: repo=file://{{ app_clone }}/{{ item.github_url | basename }} version=master dest={{ app_dir }}/{{ item.dns }}/clone
{'fraction_non_alphanumeric': 0.1296551724137931, 'fraction_numerical': 0.0, 'mean_word_length': 4.027729636048527, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 9, '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': '2336256', 'n_tokens_mistral': 1001, 'n_tokens_neox': 969, 'n_words': 349}