Skip to content
Snippets Groups Projects
Commit a5e206a5 authored by nimrod's avatar nimrod
Browse files

- Few cleanups, correct tests.

parent 5f2dedc5
No related branches found
No related tags found
No related merge requests found
......@@ -9,3 +9,5 @@ __pycache__
.vagrant/
*.log
*.retry
tests/files/id_rsa
tests/files/id_rsa.pub
[submodule ".molecule/roles/openbsd-bootstrap"]
path = .molecule/roles/openbsd-bootstrap
url = https://www.shore.co.il/git/ansible-role-openbsd-bootstrap
openbsd-bootstrap @ 87b397b1
Subproject commit 87b397b1f5abe8cc7a89cb922c4c8d7df8898204
---
# tasks file for ansible-role-gitreceive
- name: Assertions
assert:
that:
- ansible_os_family in ['Debian', 'OpenBSD']
- gitreceive_public_keys is iterable
- name: APT install prequisites
when: ansible_pkg_mgr == 'apt'
......@@ -46,13 +46,15 @@
- name: Install
when: gitreceive_fetch.changed
command: /usr/bin/make
tags: ['skip_ansible_lint']
command: make
args:
chdir: /root/gitreceive
- name: Init
tags: ['skip_ansible_lint']
when: gitreceive_fetch.changed
command: /usr/local/bin/gitreceive init
command: gitreceive init
- name: Add public keys
with_items: '{{ gitreceive_public_keys }}'
......@@ -64,8 +66,8 @@
- name: Copy reciever script
when: gitreceive_receiver_script is defined
template:
src: gitreceive_receiver.j2
copy:
content: '{{ gitreceive_receiver_script }}'
dest: /home/git/receiver
owner: git
group: git
......
{{ gitreceive_receiver_script }}
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAoSJcYqXgO8B8L34QtsdGjC0mlF8Ee9avR3M91G6B+ki8PURd
8iBJCsAUlue+I/ojUbQet2YjMYmRKB6vjRTOSSmc9BujkDKrM2UU+edpnbL7q/N2
Hyhh/t07zRi1OIDl+08mcBRdPNrR5uk3t3J5iNPD5xqoUt4XftBBjcRU7IEA7vOR
WljPfYkvdY8VmHaivD61N9LQLbCkXUXlwJRj6GctMSGrwabCQuYbIw4yCvVHdJm9
bOcdMrbuHd+cfZUHHUWt/YKGMuzNpLprSHt5Miy/XixDdD6CcyZ3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UEwBeNfKcwhECzYdlCi8M4HlgXRpndRq666taFsGdyZYkJZDXmXiN
fTlBAoGBAJ5GPrG5fpTmo1Pcot4MU3iA2L0/auc9qtXDARJpBJdXYF/a3KWGLmvT
+G0PHQ82z1Yn9qIgc4cD3A9FpUnEY8kPagpTHpwLCjGBpx5VPRmIwpGPy6zuP1gQ
w1GRFfHjaWq16KKomhVFkxBuMKwAs8v1rGXMQ2DZsDXB8GssP6Cu
-----END RSA PRIVATE KEY-----
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChIlxipeA7wHwvfhC2x0aMLSaUXwR71q9Hcz3UboH6SLw9RF3yIEkKwBSW574j+iNRtB63ZiMxiZEoHq+NFM5JKZz0G6OQMqszZRT552mdsvur83YfKGH+3TvNGLU4gOX7TyZwFF082tHm6Te3cnmI08PnGqhS3hd+0EGNxFTsgQDu85FaWM99iS91jxWYdqK8PrU30tAtsKRdReXAlGPoZy0xIavBpsJC5hsjDjIK9Ud0mb1s5x0ytu4d35x9lQcdRa39goYy7M2kumtIe3kyLL9eLEN0PoJzJnezqwbc80Bv5zT9LzpDcwVk01E0ZchBjAeodwczgqnao5rZn4jx nimrod@nimrod
#!/bin/sh
set -eu
mkdir -p /tmp/gitreceive
tar -xC /tmp/gitreceive -f -
mkdir -p /var/tmp/gitreceive
tar -xC /var/tmp/gitreceive -f -
echo "OK"
---
- hosts: ansible-role-gitreceive-openbsd
gather_facts: false
roles: [ansible-role-openbsd-bootstrap]
roles: [openbsd-bootstrap]
- hosts: all
vars:
gitreceive_public_keys:
- '{{ lookup("file", "id_rsa.pub") }}'
gitreceive_receiver_script: '{{ lookup("file", "files/receiver.sh") }}'
pre_tasks:
- name: Create SSH keypair
become: False
local_action: command ssh-keygen -t rsa -N '' -f files/id_rsa
args:
creates: files/id_rsa
roles: [ansible-role-gitreceive]
post_tasks:
- name: Create .ssh directory
......@@ -35,9 +41,9 @@
creates: /root/.ssh/known_hosts
- name: Add localhost as a git remote
command: git remote add test git@localhost:test
args:
chdir: /root/gitreceive
register: gitreceive_add_remote
changed_when: gitreceive_add_remote.rc == 0
failed_when: gitreceive_add_remote.rc != 0 and not 'already exists' in gitreceive_add_remote.stderr
blockinfile:
dest: /root/gitreceive/.git/config
block: |
[remote "test"]
url = git@localhost:test
fetch = +refs/heads/*:refs/remotes/test/*
def test_gitreceive(Command, Ansible):
Command('rm -rf /home/git/test /tmp/gitreceive')
def test_gitreceive(Command, Sudo):
with Sudo():
Command('rm -rf /home/git/test /var/tmp/gitreceive')
push = Command('git -C /root/gitreceive push test master')
assert push.rc == 0
assert 'OK' in push.stderr
with Sudo():
second_push = Command('git -C /root/gitreceive push test master')
assert second_push.rc == 0
assert 'Everything up-to-date' == second_push.stderr
assert 'Everything up-to-date' in second_push.stderr
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment