Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit e69cc66

Browse files
committed
Add name and modernize the playbook
1 parent 1afd5ec commit e69cc66

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

tasks/main.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
- name: install packages
3-
action: "{{ ansible_pkg_mgr }} pkg={{ item }} state=installed"
2+
- name: Install packages
3+
package: name={{ item }} state=present
44
with_items:
55
- rubygem-bundler
66
- ruby-devel
@@ -18,17 +18,19 @@
1818
- zlib-devel
1919
- PyYAML
2020

21-
- name: install packages
22-
action: "{{ ansible_pkg_mgr }} pkg={{ item }} state=installed"
21+
- name: Install more packages for Fedora
22+
package: name={{ item }} state=present
2323
with_items:
2424
- redhat-rpm-config
2525
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version >= '23'
2626

2727
- set_fact: checkout_dir="/srv/builder/{{ name }}"
2828

29-
- copy: dest=/usr/local/bin/build_deploy.py src=build_deploy.py mode=755 owner=root group=root
29+
- name: Deploy the build script
30+
copy: dest=/usr/local/bin/build_deploy.py src=build_deploy.py mode=755 owner=root group=root
3031

31-
- user:
32+
- name: Create {{ builder_username }} to build
33+
user:
3234
name="{{ builder_username }}"
3335
comment="Middleman builder user"
3436
generate_ssh_key=yes
@@ -37,15 +39,18 @@
3739
register: result
3840

3941
# needed so NRPE can check log
40-
- file: path="/srv/builder" mode=755 state=directory
42+
- name: Fix directory permission for NRPE
43+
file: path="/srv/builder" mode=755 state=directory
4144

4245

43-
- git: repo="{{ git_url }}" dest="{{ checkout_dir }}" version="{{ git_version | default( "HEAD" ) }}" update="no"
46+
- name: Clone git repo {{ git_url }}
47+
git: repo="{{ git_url }}" dest="{{ checkout_dir }}" version="{{ git_version | default( "HEAD" ) }}" update="no"
4448
become: yes
4549
become_user: '{{ builder_username }}'
4650
become_method: 'su'
4751

48-
- command: chdir="{{ checkout_dir }}" bundle install
52+
- name: Install gems required to build
53+
command: chdir="{{ checkout_dir }}" bundle install
4954
become: yes
5055
become_user: '{{ builder_username }}'
5156
become_method: 'su'
@@ -57,12 +62,15 @@
5762
rsync_url: "{{ rsync_user }}@{{ rsync_server }}:{{rsync_location}}"
5863
when: rsync_server is defined and rsync_location is defined and rsync_user is defined
5964

60-
- template: dest=/srv/builder/{{ name }}.yml src=builder.yml
65+
- name: Deploy yaml config for {{ name }}
66+
template: dest=/srv/builder/{{ name }}.yml src=builder.yml
6167

62-
- cron: name="build and deploy {{ name }}" job="/usr/local/bin/build_deploy.py /srv/builder/{{ name }}.yml" user="{{ builder_username }}"
68+
- name: Add cron to build {{ name }}
69+
cron: name="build and deploy {{ name }}" job="/usr/local/bin/build_deploy.py /srv/builder/{{ name }}.yml" user="{{ builder_username }}"
6370

6471
# TODO add ip restriction
65-
- authorized_key:
72+
- name: Copy the key on the other side
73+
authorized_key:
6674
key="{{ result.ssh_public_key }}"
6775
key_options="command=\"rsync --server -vlogDtprze.isf --delete-after . {{ rsync_location }}\",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty"
6876
user="{{ rsync_user }}"

0 commit comments

Comments
 (0)