-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ansible): playbook for staring the clients
- Loading branch information
1 parent
6aff628
commit 74510d5
Showing
2 changed files
with
85 additions
and
0 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,83 @@ | ||
--- | ||
- name: Setup Olde World Cluster - API | ||
hosts: '{{ variable_host | default("null") }}' | ||
gather_facts: false | ||
tasks: | ||
- name: Clone the Git Repository | ||
git: | ||
name: https://github.com/freeCodeCamp/client-config.git | ||
dest: /home/freecodecamp/client | ||
clone: true | ||
update: false | ||
single_branch: true | ||
version: master | ||
|
||
- name: Get the Node.js version | ||
shell: | ||
cmd: | | ||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] | ||
printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | ||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" | ||
node -v | ||
chdir: /home/freecodecamp/client | ||
executable: /bin/bash | ||
register: node_version_output | ||
|
||
- name: Set the Node.js version fact | ||
set_fact: | ||
node_version: '{{ node_version_output.stdout }}' | ||
|
||
- name: Install Global Dependencies | ||
shell: | ||
cmd: | | ||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] | ||
printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | ||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" | ||
npm i -g npm | ||
npm i -g pm2 | ||
npm install -g serve@13 | ||
pm2 install pm2-logrotate | ||
chdir: /home/freecodecamp/client | ||
executable: /bin/bash | ||
|
||
- name: Setup PM2 & Logrotate | ||
shell: | ||
cmd: | | ||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] | ||
printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | ||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" | ||
pm2 update | ||
pm2 install pm2-logrotate | ||
sudo env PATH=$PATH:/home/freecodecamp/.nvm/versions/node/{{ node_version }}/bin /home/freecodecamp/.nvm/versions/node/{{ node_version }}/lib/node_modules/pm2/bin/pm2 startup systemd -u freecodecamp --hp /home/freecodecamp | ||
pm2 save | ||
chdir: /home/freecodecamp/client | ||
executable: /bin/bash | ||
register: pm2_setup_output | ||
|
||
- name: Start up Client services | ||
shell: | ||
cmd: | | ||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] | ||
printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | ||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" | ||
echo "serve -c ../serve.json -p 50505 www" > client-start-primary.sh | ||
chmod +x client-start-primary.sh | ||
pm2 delete client-primary | ||
pm2 start ./client-start-primary.sh --name client-primary | ||
echo "serve -c ../serve.json -p 52525 www" > client-start-secondary.sh | ||
chmod +x client-start-secondary.sh | ||
pm2 delete client-secondary | ||
pm2 start ./client-start-secondary.sh --name client-secondary | ||
pm2 save | ||
chdir: /home/freecodecamp/client | ||
executable: /bin/bash | ||
|
||
- name: Save the running process | ||
shell: | ||
cmd: | | ||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] | ||
printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | ||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" | ||
pm2 save | ||
chdir: /home/freecodecamp/client | ||
executable: /bin/bash |