diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..29b285d --- /dev/null +++ b/.drone.yml @@ -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] diff --git a/README.md b/README.md index 33f2cc0..8ad3dcb 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/defaults/main.yml b/defaults/main.yml index e8909e9..5938484 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: diff --git a/meta/main.yml b/meta/main.yml index cd9e2af..ca32776 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -8,7 +8,3 @@ galaxy_info: - name: Ubuntu versions: - all - categories: - - system - - diff --git a/tasks/install.yml b/tasks/install.yml index 452cb6d..3c2f0fa 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -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: @@ -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 diff --git a/tests/test.yml b/tests/test.yml index e552668..4a25c68 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -24,17 +24,9 @@ git_url: "git@github.com: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