Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize and enhance agent installation, reinstallation, and update playbooks #103

Merged
merged 5 commits into from
Jul 16, 2024

Conversation

rtuszik
Copy link
Contributor

@rtuszik rtuszik commented Jul 14, 2024

Changes

  • Implemented NVM for Node.js and npm installation
  • Improved error handling for Node.js and npm checks
  • Enhanced PM2 setup with log rotation
  • Refined installation directory cleaning process
  • Optimized environment variable and host ID handling
  • Streamlined agent build and start process

Why

The previous script encountered issues during deployments on various target devices. These enhancements aim to improve reliability and consistency across different environments.

How

  • Used NVM to ensure consistent Node.js and npm versions
  • Added more robust checks for existing installations
  • Implemented thorough cleaning of the installation directory
  • Refined PM2 configuration and startup procedures
  • Optimized task ordering for improved efficiency

Testing

  • Tested on multiple target devices
  • Successfully addressed issues encountered with the previous version
  • Verified improved reliability across various environments

rtuszik added 2 commits July 14, 2024 23:21
This commit significantly improves the existing Ansible playbook for reinstalling the SquirrelServersManager agent. Key enhancements include:

- Implement NVM for consistent Node.js and npm installation
- Improve error handling and checks for Node.js and npm
- Enhance PM2 setup with log rotation and startup configuration
- Implement more thorough cleaning of installation directory
- Improve handling of environment variables and host ID
- Refine build and start process for the agent

These changes address several issues encountered during previous deployments, making the script more robust and reliable across various target devices.
@rtuszik rtuszik changed the title # Enhanced SquirrelServersManager Agent Reinstallation Script Enhanced SquirrelServersManager Agent Reinstallation Script Jul 14, 2024
@rtuszik rtuszik changed the title Enhanced SquirrelServersManager Agent Reinstallation Script Enhanced Agent Reinstallation Script Jul 14, 2024
@SquirrelDeveloper
Copy link
Collaborator

Hi @rtuszik . Thanks very much for your contribution. My code is not very DRY right now regarding the playbooks, could you consider also implementing your changes to the _installAgent and _updateAgent playbooks ?

@rtuszik
Copy link
Contributor Author

rtuszik commented Jul 15, 2024

Hi @SquirrelDeveloper.
No worries, I'll get onto that later!

rtuszik added 2 commits July 15, 2024 16:35
…ality

- Add NVM installation and configuration for consistent Node.js management
- Improve Node.js and npm version checks and installations
- Implement Git installation check and conditional installation
- Use shell module with NVM sourcing for npm and PM2 commands
- Enhance error handling and reporting throughout the playbook
- Add PM2 update step for better process management
- Include final execution status report for improved feedback
- Standardize directory cleaning and file management tasks
- Ensure consistent environment setup across fresh installs and reinstalls
… _installAgent.yml

- Add NVM directory variable for consistent Node.js management
- Implement Node.js and npm version verification and display
- Replace raw commands with shell module for npm and PM2 operations
- Improve error handling in npm, build, and PM2 start tasks
- Standardize directory cleaning using file module
- Add PM2 update step after agent installation
- Include execution status report at the end of playbook
- Ensure all shell commands source NVM before execution
@rtuszik rtuszik changed the title Enhanced Agent Reinstallation Script Standardize and enhance agent installation, reinstallation, and update playbooks Jul 15, 2024
@rtuszik
Copy link
Contributor Author

rtuszik commented Jul 15, 2024

@SquirrelDeveloper, done. Updated _installAgent.yml and _updateAgent.yml to match _reinstallAgent.yml. All three playbooks are now in sync.

@SquirrelDeveloper SquirrelDeveloper added the chores Refactoring or small updates label Jul 15, 2024
@SquirrelDeveloper SquirrelDeveloper added this to the v0.1.16 milestone Jul 15, 2024
@SquirrelDeveloper
Copy link
Collaborator

@rtuszik Thank you very much for your contribution, I will test it asap

@SquirrelDeveloper
Copy link
Collaborator

SquirrelDeveloper commented Jul 15, 2024

@rtuszik Thanks a lot.
It was not working at first, I found that the executable was missing in args in several nvm shell command --> https://github.com/SquirrelCorporation/SquirrelServersManager/pull/111/files

You can either update the PR or will merge the new one.

On a side note, it got me deep, deep into an Ansible/NVM rabbit hole though.
In a future version, to be as much as generic and compatible as possible, the playbook should support multiple shells and install methods for NVM. Installing the agent with NVM could be like that POC : https://github.com/SquirrelCorporation/SquirrelServersManager/compare/chore-super-install-agent?expand=1#diff-e892a879b8454a25b9686b4900645b65c9c3b37f22210df250f1bbe0bd43a1d4

@rtuszik
Copy link
Contributor Author

rtuszik commented Jul 15, 2024

True. Worked fine for me so I missed that part. Just merged the changes. I agree, there is lots of room for improvement. Just hopped on to make it functional and make it work for now.

@SquirrelDeveloper SquirrelDeveloper merged commit 791957a into SquirrelCorporation:master Jul 16, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chores Refactoring or small updates
Projects
Development

Successfully merging this pull request may close these issues.

2 participants