200-901 · Question #559
200-901 Question #559: Real Exam Question with Answer & Explanation
The correct workflow involves first setting up connection variables, then establishing the remote connection, followed by retrieving the new application code, installing its dependencies, and finally restarting the application to apply changes.
Question
Drag and Drop Question Refer to the exhibit. A developer is responsible for managing an application. The developer wants to deploy the new version of the application on the test environment whenever it is released. To automate this workflow, the developer writes a bash script. Drag and drop the deployment steps from the left into the order on the right to identify the workflow that is automated by the script. Answer:
Explanation
The correct workflow involves first setting up connection variables, then establishing the remote connection, followed by retrieving the new application code, installing its dependencies, and finally restarting the application to apply changes.
Approach. To correctly order the deployment steps, one must analyze the bash script line by line and map its actions to the provided draggable options:
- creates variables for remote execution: Script lines 2-6 (
SSH_KEY_PATH,SERVER,DEST_FOLDER,PARAMS) define essential variables required for the subsequent remote connection and deployment tasks. These must be set before any connection attempt. - connects to the server: Script line 8 (
ssh -i $SSH_KEY_PATH $SERVER $PARAMS 'bash -i' <<-'ENDSSH') initiates the secure shell connection to the remote server using the variables defined in the previous step. This is the first actual interaction with the remote server. - places a new application version on the server: Once connected, script lines 11-14 (
git stash,git pull,git checkout $BRANCH,git pull origin $BRANCH) fetch the latest application code from the Git repository, effectively updating or placing a new version of the application on the server. - installs the application: After the new code is in place, script lines 16-17 (
rm -rf node_modules/,npm install) remove old dependencies and install the necessary new dependencies for the updated application. This is a crucial part of preparing the application to run. - restarts the application: Finally, script lines 19-21 (
pm2 stop app_name,pm2 start app_name,pm2 save) stop the currently running application instance, start the newly updated and installed version, and save the process list. This brings the new application version online and makes it accessible.
Therefore, the correct order is: creates variables for remote execution -> connects to the server -> places a new application version on the server -> installs the application -> restarts the application.
Common mistakes.
- common_mistake. A common mistake would be to place 'connects to the server' before 'creates variables for remote execution'. The SSH command relies on the variables like
SSH_KEY_PATHandSERVERbeing defined first. Another mistake could be reversing the order of 'places a new application version on the server' and 'installs the application'. You must first have the new application code on the server (viagit pull) before you can install its specific dependencies (npm install). Similarly, restarting the application should be the final step after all code updates and dependency installations are complete to ensure the new version is loaded.
Concept tested. Understanding of basic bash scripting, remote execution (SSH), application deployment workflows, version control with Git, Node.js package management (npm), and process management (pm2). The question tests the ability to interpret a script and identify the logical sequence of operations in a common DevOps scenario.
Topics
Community Discussion
No community discussion yet for this question.