| 1 | --- |
| 2 | - name: Install cgit |
| 3 | ansible.builtin.apt: |
| 4 | name: ['cgit', 'apache2'] |
| 5 | - include_role: |
| 6 | name: common |
| 7 | tasks_from: certs |
| 8 | - name: Configure cgit |
| 9 | ansible.builtin.template: |
| 10 | src: cgitrc.j2 |
| 11 | dest: /etc/cgitrc |
| 12 | - name: Configure apache2 |
| 13 | block: |
| 14 | - name: Enable cgit configuration |
| 15 | ansible.builtin.command: |
| 16 | argv: ['a2enconf', 'cgit.conf'] |
| 17 | creates: /etc/apache2/conf-enabled/cgit.conf |
| 18 | notify: |
| 19 | - Restart apache |
| 20 | - name: Disable default site |
| 21 | ansible.builtin.command: |
| 22 | argv: ['a2dissite', '000-default.conf'] |
| 23 | removes: /etc/apache2/sites-enabled/000-default.conf |
| 24 | notify: |
| 25 | - Restart apache |
| 26 | - name: Enable https |
| 27 | ansible.builtin.command: |
| 28 | argv: ['a2enmod', 'ssl'] |
| 29 | creates: '/etc/apache2/mods-enabled/ssl.conf' |
| 30 | notify: |
| 31 | - Restart apache |
| 32 | - name: Enable cgid |
| 33 | ansible.builtin.command: |
| 34 | argv: ['a2enmod', 'cgid'] |
| 35 | creates: '/etc/apache2/mods-enabled/cgid.conf' |
| 36 | notify: |
| 37 | - Restart apache |
| 38 | - name: Manage apache2 cgit site configuration |
| 39 | ansible.builtin.template: |
| 40 | src: apache2.conf.j2 |
| 41 | dest: /etc/apache2/sites-available/cgit.conf |
| 42 | notify: |
| 43 | - Restart apache |
| 44 | - name: Enable cgit site configuration |
| 45 | ansible.builtin.command: |
| 46 | argv: ['a2ensite', 'cgit.conf'] |
| 47 | creates: /etc/apache2/sites-enabled/cgit.conf |
| 48 | notify: |
| 49 | - Restart apache |
| 50 | - name: Install git-daemon |
| 51 | ansible.builtin.apt: |
| 52 | name: ['git-daemon-sysvinit'] |
| 53 | - name: Create git-daemon base path |
| 54 | when: git_daemon_conf.GIT_DAEMON_BASE_PATH |
| 55 | ansible.builtin.file: |
| 56 | path: "{{git_daemon_conf.GIT_DAEMON_BASE_PATH}}" |
| 57 | state: directory |
| 58 | owner: gitdaemon |
| 59 | group: gitdaemon |
| 60 | - name: Configure git-daemon |
| 61 | with_items: "{{git_daemon_conf|dict2items}}" |
| 62 | community.general.ini_file: |
| 63 | path: /etc/default/git-daemon |
| 64 | option: "{{item.key}}" |
| 65 | value: "{{item.value}}" |
| 66 | no_extra_spaces: true |
| 67 | notify: |
| 68 | - Restart git-daemon |
| 69 | - name: Create git-daemon group |
| 70 | ansible.builtin.group: |
| 71 | system: true |
| 72 | name: gitdaemon |
| 73 | - name: Add www-data to the git-daemon group |
| 74 | ansible.builtin.user: |
| 75 | name: www-data |
| 76 | append: true |
| 77 | groups: ['gitdaemon'] |
| 78 | - name: Install grokmirror |
| 79 | block: |
| 80 | - ansible.builtin.copy: |
| 81 | src: files/grokmirror_2.0.11-1_all.deb |
| 82 | dest: /root/grokmirror.deb |
| 83 | register: grokmirror_deb |
| 84 | - when: grokmirror_deb.changed |
| 85 | ansible.builtin.command: |
| 86 | argv: ['apt', 'install', '-y', '/root/grokmirror.deb'] |
| 87 | - ansible.builtin.file: |
| 88 | state: directory |
| 89 | dest: /etc/grokmirror |
| 90 | - name: Create grokmirror log directory |
| 91 | ansible.builtin.file: |
| 92 | state: directory |
| 93 | dest: /var/log/grokmirror |
| 94 | owner: gitdaemon |
| 95 | group: root |
| 96 | mode: '0755' |
| 97 | - ansible.builtin.file: |
| 98 | state: directory |
| 99 | dest: /storage/git-mirror/gitdaemon |
| 100 | owner: gitdaemon |
| 101 | group: gitdaemon |
| 102 | - name: Create grokmirror configs |
| 103 | include_tasks: |
| 104 | file: mirror_instance.yml |
| 105 | with_items: "{{grokmirror_instances|dict2items}}" |
| 106 | vars: |
| 107 | name: "{{item.key}}" |
| 108 | mirror: "{{item.value}}" |
| 109 | - name: Create legacy pull directory |
| 110 | ansible.builtin.file: |
| 111 | state: directory |
| 112 | dest: /storage/git-mirror/gitdaemon/git |
| 113 | owner: gitdaemon |
| 114 | group: gitdaemon |
| 115 | - name: Create legacy pull script |
| 116 | ansible.builtin.copy: |
| 117 | src: update.sh |
| 118 | dest: /storage/git-mirror/gitdaemon/git/update.sh |
| 119 | mode: '0750' |
| 120 | owner: gitdaemon |
| 121 | group: gitdaemon |
| 122 | - name: Install cron |
| 123 | ansible.builtin.apt: |
| 124 | name: cron |
| 125 | - name: Manage legacy pull cron job |
| 126 | ansible.builtin.cron: |
| 127 | name: gitmirror |
| 128 | cron_file: gitmirror |
| 129 | minute: '*/30' |
| 130 | job: 'cd /storage/git-mirror/gitdaemon/git && ./update.sh >/dev/null 2>&1' |
| 131 | user: gitdaemon |
| 132 | - name: Link cgit export directories |
| 133 | with_items: "{{cgit_export_links|dict2items}}" |
| 134 | ansible.builtin.file: |
| 135 | state: link |
| 136 | src: "{{item.value}}" |
| 137 | path: "/storage/git-mirror/gitdaemon/export/{{item.key}}" |