-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: résolution des conflits et prise en compte des retours d'ansible…
… linter
- Loading branch information
Showing
9 changed files
with
119 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: "Continuous Integration" | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
install_python_requirements: | ||
name: Install Python requirements | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
- name: Cache Python dependencies | ||
uses: actions/cache@v3 | ||
id: python-dependencies | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-python-dependencies-${{ hashFiles('**/requirements.txt') }} | ||
- name: Install dependencies | ||
run: pip install -r requirements.txt | ||
lint_ansible_files: | ||
name: Lint ansible files | ||
runs-on: ubuntu-20.04 | ||
needs: [install_python_requirements] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
- name: Cache Python dependencies | ||
uses: actions/cache@v3 | ||
id: python-dependencies | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-python-dependencies-${{ hashFiles('**/requirements.txt') }} | ||
- name: Check installed package | ||
run: pip freeze | ||
- name: Run ansible lint | ||
run: ansible-lint --offline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ virtualmachines: | |
dns_root: leonides.org # The root of domain name use by your server | ||
email: [email protected] # The email used to register Certbot | ||
github_users: # The github users that will be able to connect to the server | ||
- guillett | ||
- github_username_example | ||
monitor: # If set, a monitoring service will be deployed on specified port | ||
port: 8887 | ||
applications: # List all applications that will be deployed | ||
|
@@ -80,6 +80,13 @@ ansible-playbook -i ./inventories/vps.yaml synchronize.yaml | |
|
||
A copy of this repository will be created in the folder `/opt/mes-aides` of the server. This repository will be automatically updated and new modifications applied every time an ssh connection is made with the private key associated with the `update_key` defined in the inventory. | ||
|
||
Note: | ||
Private and public keys should be generated manually: | ||
- Private should be keys added to Github secrets variable (used [here](https://github.com/betagouv/aides-jeunes-ops/blob/9f5bd32001b1b889f580e7e14213397b7af2227b/.github/workflows/pipeline.yaml#L71) for instance) | ||
- Public keys added to `ops.update_key` variable in the inventory | ||
|
||
Warning: Launching the `synchronize.yaml` playbook alone will remove continuous deploiement of server stack. You will need to run the `bootstrap.yaml` playbook again to re-enable it. | ||
|
||
### Bootstrap server stack | ||
|
||
Run the command `ansible-playbook -i ./inventories/vps.yaml bootstrap.yaml` in order to bootstrap the server basic configuration. | ||
|
@@ -88,6 +95,17 @@ Once done, every applications should be up and running on the server. | |
|
||
Note that you only need to run this command once, but you can re-run it if you modify either Nginx, Python, Mongo configuration or if the bootstrap process failed at some point. All unaltered steps that ran successfully will be automatically skipped by Ansible. | ||
|
||
#### First deployment | ||
|
||
In order to setup continuous deployment, you will need to: | ||
- Run manually the `synchronize.yaml` playbook | ||
- Run manually the `bootstrap.yaml` playbook | ||
- Connect to the server using one of the private keys associated to your Github account | ||
- switch user to `main` | ||
- run `cd ~/` and cd the application folder you want to deploy | ||
- get the private key (see `ansible_ssh_private_key_file` in inventory) | ||
- set it up in your Github repository as a secret (see [here](https://github.com/betagouv/aides-jeunes/blob/400ab5f90219141b438388d58cd4f27f8fb0ebd6/.github/workflows/cd.yml#L48)) | ||
|
||
### Backup mongodb collections | ||
|
||
It is possible to dump mongodb collections from a server and restore them on another. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ virtualmachines: | |
dns_root: beta.gouv.fr | ||
email: [email protected] | ||
github_users: | ||
- guillett | ||
- jenovateurs | ||
- Shamzic | ||
monitor: | ||
port: 8887 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ virtualmachines: | |
dns_root: beta.gouv.fr | ||
email: [email protected] | ||
github_users: | ||
- guillett | ||
- jenovateurs | ||
- Shamzic | ||
monitor: | ||
port: 8887 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ virtualmachines: | |
dns_root: beta.gouv.fr | ||
email: [email protected] | ||
github_users: | ||
- guillett | ||
- jenovateurs | ||
- Shamzic | ||
monitor: | ||
port: 8887 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,25 @@ | ||
--- | ||
|
||
- name: Download node.js installation script | ||
get_url: | ||
ansible.builtin.get_url: | ||
url: https://deb.nodesource.com/setup_{{ node_version }}.x | ||
dest: /tmp/nodesource_setup.sh | ||
|
||
- name: make node script exectuable | ||
file: dest=/tmp/nodesource_setup.sh mode=a+x | ||
mode: '0755' | ||
|
||
- name: Run the nodesource setup script | ||
become: true | ||
command: sh /tmp/nodesource_setup.sh | ||
|
||
- name: remove exisiting package | ||
become: true | ||
apt: | ||
name: nodejs | ||
state: absent | ||
purge: true | ||
ansible.builtin.command: sh /tmp/nodesource_setup.sh | ||
args: | ||
creates: /usr/bin/node | ||
|
||
- name: update and install nodejs | ||
- name: Update and install nodejs | ||
become: true | ||
apt: | ||
ansible.builtin.apt: | ||
name: nodejs | ||
state: present | ||
update_cache: true | ||
|
||
- name: Clean up NodeSource setup script | ||
ansible.builtin.file: | ||
path: /tmp/nodesource_setup.sh | ||
state: absent | ||
state: absent |