Skip to content

Commit

Permalink
Add tests & cleanup (#1)
Browse files Browse the repository at this point in the history
- Add drone tests
- Add a task to optionally delete the git private key
- Update README
  • Loading branch information
moshthepitt authored Oct 3, 2018
1 parent 5c5338b commit 7b6bada
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 17 deletions.
17 changes: 17 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pipeline:
build:
image: ubuntu:xenial
commands:
- apt update
- apt install -y git sudo python-pip python-minimal software-properties-common curl apt-transport-https
- pip install ansible
- apt-get -y clean && apt-get -y autoclean
- ansible-playbook -i "127.0.0.1," tests/test.yml --syntax-check
- ansible-playbook -i "127.0.0.1," tests/test.yml --connection=local --become
secrets: [ git_key ]
notify:
image: plugins/slack
secrets: [ slack_webhook ]
when:
status: [success, failure]
event: [push, tag]
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
# Ansibe.React
# ansible-react

Install and configure react apps.

This is a simple and straight-to-the-point role to install react apps. it is tested against apps that were created using [create react app](https://github.com/facebook/create-react-app).

We only install and configure:

- node
- yarn
- and of course all the javascript packages that your project uses

We intentionally consider the installation and configuration of web servers, and other things as out of scope for this role. Therefore, naturally this role is to be used in a playbook that installs and configures those other things, if you need them.

## Role Variables

Some of the more important variables are briefly described below. You can see all variables by looking at the `defaults/main.yml` file.

```yml
system_user: "react" # name of the user that will own the django installation
node_version: 10.x # the version of node to install

git_url: "https://github.com/moshthepitt/django-template3.git" # the git repo of your django app which we are installing
git_key:
```
### Custom environment variables
[Create react app](https://github.com/facebook/create-react-app) supports [custom environment variables](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables) and this role does too!
You can set custom environment variables by using the `app_settings` variable, like so:

```yml
app_settings:
REACT_APP_WEBSITE_NAME: 'Example App'
SOMETHING_ELSE: "you can put anything here"
```

## Testing

This project comes with a Vagrantfile, this is a fast and easy way to test changes to the role, fire it up with `vagrant up`.
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ system_user_home: "/home/{{ system_user }}"
git_url:
git_version: "master"
git_key:
git_public_key:
git_key_filename: "id_ed25519"
remove_git_key: True

# system-wide dependencies
system_wide_dependencies:
Expand Down
4 changes: 0 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ galaxy_info:
- name: Ubuntu
versions:
- all
categories:
- system


14 changes: 12 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
become: True
become_user: "{{ system_user }}"
when:
- git_key is not defined
- git_key is none
- git_key is not defined or git_key is none

- name: Copy git key
copy:
Expand All @@ -89,3 +88,14 @@
when:
- git_key is defined
- git_key is not none

- name: Remove Git Key
file:
state: absent
path: "{{ system_user_home }}/.ssh/{{ git_key_filename }}"
become: True
become_user: "{{ system_user }}"
when:
- git_key is defined
- git_key is not none
- remove_git_key == True
10 changes: 1 addition & 9 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@
git_url: "[email protected]:onaio/kaznet-frontend.git"
git_version: "master"
git_key: |
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACA9qCTlybKhynrJk3BeoT0A7xBlqzaqg/kZdj3sK9jPKQAAAKCeaoI/nmqC
PwAAAAtzc2gtZWQyNTUxOQAAACA9qCTlybKhynrJk3BeoT0A7xBlqzaqg/kZdj3sK9jPKQ
AAAEDYh6iqUK/8egdsvLNmnW4nAcr1kcCLcoOQA3xnYPZFJD2oJOXJsqHKesmTcF6hPQDv
EGWrNqqD+Rl2Pewr2M8pAAAAF21vc2hAbW9zaC1UaGlua1BhZC1UNDcwAQIDBAUG
-----END OPENSSH PRIVATE KEY-----
{{ lookup('env', 'GIT_KEY') }}
app_settings:
REACT_APP_WEBSITE_NAME: 'Example App'
REACT_APP_KAZNET_ENDPOINT: 'http://127.0.0.1:8000/api/v1'
REACT_APP_API_TOKEN: 'a068bf9af441dcb308d2ee51295d548218757bc5'
SOMETHING_ELSE: "you can put anything here"
gather_facts: True
become: True
Expand Down

0 comments on commit 7b6bada

Please sign in to comment.