Skip to content

Commit

Permalink
Merge pull request #10 from micahmount/jammy
Browse files Browse the repository at this point in the history
Updated role syntax to work with latest Ansible and Ubuntu 22.04 lts …
  • Loading branch information
aioue authored Jun 8, 2023
2 parents cc09f90 + 9623ae0 commit 6aa5391
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
aptly_gpg_key_dir: "{{ lookup('env', 'HOME') }}"
aptly_gpg_key_dir: "aptly"
aptly_key_email: [email protected]
aptly_company_name: yourcompany
aptly_repositories:
Expand Down
25 changes: 17 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
- name: import aptly repo key
become: yes
apt_key:
id: "ED75B5A4483DA07C"
keyserver: "hkp://p80.pool.sks-keyservers.net:80"
id: "A0546A43624A8331"
keyserver: "keyserver.ubuntu.com"
state: present

- name: add aptly debian repository
become: yes
apt_repository:
repo: 'deb http://repo.aptly.info/ squeeze main'
state: present

- name: install required packages
become: yes
apt:
name: gnupg2,rng-tools,aptly
name: gnupg2,rng-tools,aptly, curl
update_cache: yes

# begin key creation tasks (automatically generates and imports a DSA key-pair to get you up and running quickly)


- name: start rngd for entropy creation
become: true
command: rngd -b -r /dev/hwrandom
Expand All @@ -44,6 +46,7 @@
creates: "{{ aptly_gpg_key_dir }}/key.sec"

- name: stop random source
become: true
service:
name: rng-tools
state: stopped
Expand All @@ -56,16 +59,22 @@
command: gpg2 --import {{ aptly_gpg_key_dir }}/key.sec
ignore_errors: yes

# ignore 'already in secret keyring' error
- name: import sec key to gnupg
command: gpg2 --import {{ aptly_gpg_key_dir }}/key.sec
ignore_errors: yes

# end key creation tasks

# CLI conflict - https://github.com/smira/aptly/issues/234
# # CLI conflict - https://github.com/smira/aptly/issues/234
- name: start aptly API (will conflict with command line until stopped)
command: sh -c "nohup aptly api serve 2>&1 >/dev/null &"
command: sh -c "nohup aptly api serve -no-lock 2>&1 >/dev/null &"

- name: create repositories
command: >
command: >-
curl -X POST -H 'Content-Type: application/json' --data '{"name": "{{ item.name }}", "comment": "{{ item.comment }}", "DefaultDistribution": "{{ item.default_distribution }}", "DefaultComponent": "{{ item.default_component }}" }' http://localhost:8080/api/repos
with_items: aptly_repositories
with_items:
- "{{ aptly_repositories }}"
when: aptly_repositories is defined

- include: test.yml
- include_tasks: test.yml
4 changes: 2 additions & 2 deletions tasks/test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---

- name: install test dependencies
sudo: true
become: true
apt: name=python-httplib2

- name: test aptly output
uri:
url: http://localhost:8080/api/repos

- name: copy dummy package
sudo: yes
become: true
copy: src=dummy_0.1_all.deb dest=/tmp

- name: upload dummy package to server
Expand Down
2 changes: 2 additions & 0 deletions templates/gpg2_gen_key.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Name-Real: {{ aptly_company_name }}
Name-Comment: aptly key no passphrase
Name-Email: {{ aptly_key_email }}
Expire-Date: 0
%no-ask-passphrase
%no-protection
%pubring {{ aptly_gpg_key_dir }}/key.pub
%secring {{ aptly_gpg_key_dir }}/key.sec
# Do a commit here, so that we can later print "done" :-)
Expand Down

0 comments on commit 6aa5391

Please sign in to comment.