├── .ansible-lint ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ ├── release.yml │ └── stale.yml ├── .gitignore ├── .yamllint ├── LICENSE ├── README.md ├── defaults └── main.yml ├── files └── svnserve ├── meta └── main.yml ├── molecule └── default │ ├── converge.yml │ ├── molecule.yml │ └── requirements.yml ├── tasks └── main.yml ├── templates └── subversion.conf.j2 └── vars ├── Debian.yml └── RedHat.yml /.ansible-lint: -------------------------------------------------------------------------------- 1 | skip_list: 2 | - 'yaml' 3 | - 'role-name' 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | --- 3 | github: geerlingguy 4 | patreon: geerlingguy 5 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "0 1 * * 2" 10 | 11 | defaults: 12 | run: 13 | working-directory: 'geerlingguy.svn' 14 | 15 | jobs: 16 | 17 | lint: 18 | name: Lint 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Check out the codebase. 22 | uses: actions/checkout@v4 23 | with: 24 | path: 'geerlingguy.svn' 25 | 26 | - name: Set up Python 3. 27 | uses: actions/setup-python@v5 28 | with: 29 | python-version: '3.x' 30 | 31 | - name: Install test dependencies. 32 | run: pip3 install yamllint 33 | 34 | - name: Lint code. 35 | run: | 36 | yamllint . 37 | 38 | molecule: 39 | name: Molecule 40 | runs-on: ubuntu-latest 41 | strategy: 42 | matrix: 43 | distro: 44 | - rockylinux9 45 | - ubuntu2404 46 | - debian12 47 | 48 | steps: 49 | - name: Check out the codebase. 50 | uses: actions/checkout@v4 51 | with: 52 | path: 'geerlingguy.svn' 53 | 54 | - name: Set up Python 3. 55 | uses: actions/setup-python@v5 56 | with: 57 | python-version: '3.x' 58 | 59 | - name: Install test dependencies. 60 | run: pip3 install ansible molecule molecule-plugins[docker] docker 61 | 62 | - name: Run Molecule tests. 63 | run: molecule test 64 | env: 65 | PY_COLORS: '1' 66 | ANSIBLE_FORCE_COLOR: '1' 67 | MOLECULE_DISTRO: ${{ matrix.distro }} 68 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow requires a GALAXY_API_KEY secret present in the GitHub 3 | # repository or organization. 4 | # 5 | # See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy 6 | # See: https://github.com/ansible/galaxy/issues/46 7 | 8 | name: Release 9 | 'on': 10 | push: 11 | tags: 12 | - '*' 13 | 14 | defaults: 15 | run: 16 | working-directory: 'geerlingguy.svn' 17 | 18 | jobs: 19 | 20 | release: 21 | name: Release 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Check out the codebase. 25 | uses: actions/checkout@v4 26 | with: 27 | path: 'geerlingguy.svn' 28 | 29 | - name: Set up Python 3. 30 | uses: actions/setup-python@v5 31 | with: 32 | python-version: '3.x' 33 | 34 | - name: Install Ansible. 35 | run: pip3 install ansible-core 36 | 37 | - name: Trigger a new import on Galaxy. 38 | run: >- 39 | ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} 40 | $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) 41 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Close inactive issues 3 | 'on': 4 | schedule: 5 | - cron: "55 5 * * 5" # semi-random time 6 | 7 | jobs: 8 | close-issues: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | issues: write 12 | pull-requests: write 13 | steps: 14 | - uses: actions/stale@v8 15 | with: 16 | days-before-stale: 120 17 | days-before-close: 60 18 | exempt-issue-labels: bug,pinned,security,planned 19 | exempt-pr-labels: bug,pinned,security,planned 20 | stale-issue-label: "stale" 21 | stale-pr-label: "stale" 22 | stale-issue-message: | 23 | This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 24 | 25 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 26 | close-issue-message: | 27 | This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 28 | stale-pr-message: | 29 | This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 30 | 31 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 32 | close-pr-message: | 33 | This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 34 | repo-token: ${{ secrets.GITHUB_TOKEN }} 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | */__pycache__ 3 | *.pyc 4 | .cache 5 | 6 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 120 7 | level: warning 8 | 9 | ignore: | 10 | .github/workflows/stale.yml 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Jeff Geerling 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: SVN 2 | 3 | [![CI](https://github.com/geerlingguy/ansible-role-svn/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-svn/actions/workflows/ci.yml) 4 | 5 | Installs [Apache SVN](https://subversion.apache.org/) (Subversion) on any RHEL/CentOS or Debian/Ubuntu Linux system. 6 | 7 | ## Requirements 8 | 9 | The `svnserve` service, which allows access to repositories via the `svn://` protocol runs on port 3690 by default, so please make sure that port is open on your firewall. 10 | 11 | ## Role Variables 12 | 13 | Available variables are listed below, along with default values (see `defaults/main.yml`): 14 | 15 | svn_repository_home: /var/svn 16 | 17 | The SVN repository directory that will be served by `svnserve` through Apache. 18 | 19 | svn_create_test_repo: true 20 | 21 | Whether to create a example respository 'testrepo', which will be available at `http://[hostname]/svn/testrepo`. 22 | 23 | ## Dependencies 24 | 25 | - geerlingguy.apache 26 | 27 | ## Example Playbook 28 | 29 | - hosts: servers 30 | roles: 31 | - geerlingguy.svn 32 | 33 | ## License 34 | 35 | MIT / BSD 36 | 37 | ## Author Information 38 | 39 | This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). 40 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | svn_repository_home: /var/svn 3 | svn_create_test_repo: true 4 | -------------------------------------------------------------------------------- /files/svnserve: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: svnserve 4 | # Required-Start: $local_fs $syslog $remote_fs 5 | # Required-Stop: $local_fs $syslog $remote_fs 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Start svnserve 9 | ### END INIT INFO 10 | 11 | # Author: Michal Wojciechowski 12 | 13 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 14 | DESC="svnserve" 15 | NAME=svnserve 16 | DAEMON=/usr/bin/$NAME 17 | DAEMON_ARGS="-d -r /usr/local/svn/repos" 18 | PIDFILE=/var/run/$NAME.pid 19 | SCRIPTNAME=/etc/init.d/$NAME 20 | 21 | [ -x "$DAEMON" ] || exit 0 22 | 23 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 24 | 25 | . /lib/init/vars.sh 26 | 27 | . /lib/lsb/init-functions 28 | 29 | do_start() 30 | { 31 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ 32 | || return 1 33 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ 34 | $DAEMON_ARGS \ 35 | || return 2 36 | } 37 | 38 | do_stop() 39 | { 40 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME 41 | RETVAL="$?" 42 | [ "$RETVAL" = 2 ] && return 2 43 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON 44 | [ "$?" = 2 ] && return 2 45 | rm -f $PIDFILE 46 | return "$RETVAL" 47 | } 48 | 49 | case "$1" in 50 | start) 51 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 52 | do_start 53 | case "$?" in 54 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 55 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 56 | esac 57 | ;; 58 | stop) 59 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 60 | do_stop 61 | case "$?" in 62 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 63 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 64 | esac 65 | ;; 66 | restart|force-reload) 67 | log_daemon_msg "Restarting $DESC" "$NAME" 68 | do_stop 69 | case "$?" in 70 | 0|1) 71 | do_start 72 | case "$?" in 73 | 0) log_end_msg 0 ;; 74 | 1) log_end_msg 1 ;; # Old process is still running 75 | *) log_end_msg 1 ;; # Failed to start 76 | esac 77 | ;; 78 | *) 79 | # Failed to stop 80 | log_end_msg 1 81 | ;; 82 | esac 83 | ;; 84 | *) 85 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 86 | exit 3 87 | ;; 88 | esac 89 | 90 | exit 0 91 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: 3 | - geerlingguy.apache 4 | 5 | galaxy_info: 6 | role_name: svn 7 | author: geerlingguy 8 | description: SVN web server for Linux 9 | company: "Midwestern Mac, LLC" 10 | license: "license (BSD, MIT)" 11 | min_ansible_version: 2.10 12 | platforms: 13 | - name: Debian 14 | versions: 15 | - all 16 | - name: Ubuntu 17 | versions: 18 | - all 19 | galaxy_tags: 20 | - development 21 | - svn 22 | - subversion 23 | - vcs 24 | -------------------------------------------------------------------------------- /molecule/default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | #become: true 5 | 6 | pre_tasks: 7 | - name: Update apt cache. 8 | apt: update_cache=true cache_valid_time=600 9 | when: ansible_os_family == 'Debian' 10 | 11 | roles: 12 | - role: geerlingguy.apache 13 | - role: geerlingguy.svn 14 | 15 | post_tasks: 16 | - name: Ensure Apache is serving the test repo. 17 | uri: 18 | url: "http://127.0.0.1/svn/testrepo/" 19 | status_code: 200 20 | register: result 21 | until: result.status == 200 22 | retries: 60 23 | delay: 1 24 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | role_name_check: 1 3 | dependency: 4 | name: galaxy 5 | options: 6 | ignore-errors: true 7 | driver: 8 | name: docker 9 | platforms: 10 | - name: instance 11 | image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest" 12 | command: ${MOLECULE_DOCKER_COMMAND:-""} 13 | volumes: 14 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 15 | cgroupns_mode: host 16 | privileged: true 17 | pre_build_image: true 18 | provisioner: 19 | name: ansible 20 | playbooks: 21 | converge: ${MOLECULE_PLAYBOOK:-converge.yml} 22 | -------------------------------------------------------------------------------- /molecule/default/requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - src: geerlingguy.apache 3 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Include OS-specific variables. 3 | include_vars: "{{ ansible_os_family }}.yml" 4 | 5 | - name: Ensure SVN packages are installed. 6 | package: 7 | name: "{{ svn_packages }}" 8 | state: present 9 | 10 | - name: Ensure svn home folder exists. 11 | file: 12 | path: "{{ svn_repository_home }}" 13 | state: directory 14 | mode: 0755 15 | 16 | - name: Copy subversion configuration file. 17 | template: 18 | src: subversion.conf.j2 19 | dest: "{{ svn_apache_conf_path }}/subversion.conf" 20 | owner: root 21 | group: root 22 | mode: 0644 23 | notify: restart apache 24 | 25 | - name: Create a test repository. 26 | command: > 27 | svnadmin create testrepo 28 | chdir={{ svn_repository_home }} 29 | creates={{ svn_repository_home }}/testrepo/README.txt 30 | when: svn_create_test_repo 31 | 32 | - name: Set ownership for svn directories. 33 | file: # noqa 208 34 | path: "{{ svn_repository_home }}" 35 | owner: "{{ svn_apache_user }}" 36 | group: "{{ svn_apache_user }}" 37 | recurse: true 38 | notify: restart apache 39 | 40 | - name: Create init script for svnserve (Debian). 41 | copy: 42 | src: svnserve 43 | dest: /etc/init.d/svnserve 44 | mode: 0755 45 | when: ansible_os_family == 'Debian' 46 | register: svn_init_copy 47 | 48 | # Workaround for bug https://github.com/ansible/ansible-modules-core/issues/915. 49 | - name: Run systemd daemon_reload (Ubuntu/Debian workaround). 50 | systemd: 51 | name: svnserve 52 | daemon_reload: true 53 | when: 54 | - svn_init_copy.changed 55 | - ansible_os_family == 'Debian' 56 | - ansible_service_mgr == 'systemd' 57 | tags: ['skip_ansible_lint'] 58 | 59 | - name: Ensure SVN is started. 60 | service: name=svnserve state=started enabled=yes 61 | -------------------------------------------------------------------------------- /templates/subversion.conf.j2: -------------------------------------------------------------------------------- 1 | LoadModule dav_svn_module modules/mod_dav_svn.so 2 | LoadModule authz_svn_module modules/mod_authz_svn.so 3 | 4 | 5 | DAV svn 6 | SVNParentPath {{ svn_repository_home }} 7 | Allow from All 8 | 9 | -------------------------------------------------------------------------------- /vars/Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | svn_apache_user: www-data 3 | svn_apache_conf_path: /etc/apache2/sites-enabled 4 | svn_packages: 5 | - subversion 6 | - libapache2-mod-svn 7 | -------------------------------------------------------------------------------- /vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | svn_apache_user: apache 3 | svn_apache_conf_path: /etc/httpd/conf.d 4 | svn_packages: 5 | - mod_dav_svn 6 | - subversion 7 | --------------------------------------------------------------------------------