Creating train-schedule service to get pipeline to deploy

Was able to get the Continuous Delivery pipeline to deploy to staging and production but I'm wondering if I missed a section. I saw the notes that pre-work was done (creating deploy users on the staging and production nodes with sudo, creating a webhook in GitHub and creating a train-schedule service on the staging and production nodes. I created a train-schedule service to get pipeline to deploy. Did anyone else find this necessary or did I miss a step?

  • post-author-pic
    Will B
    09-17-2018

    You do need to set up the service on both the staging and production servers. It sounds like you were able to do it, but I'll provide my steps that I used in case you want to get more clarity, or in case anyone else needs help with that part:

    adduser deploy
    echo "deploy:jenkins" | chpasswd
    groupadd train-schedule
    usermod -a -G train-schedule deploy
    echo "deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop train-schedule" >> /etc/sudoers
    echo "deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl start train-schedule" >> /etc/sudoers
    echo -e "[Unit]\\nDescription=Train Schedule\\nAfter=network.target\\n\\n[Service]\\n\\nType=simple\\nWorkingDirectory=/opt/train-schedule\\nExecStart=/usr/bin/node bin/www\\nStandardOutput=syslog\\nStandardError=syslog\\nRestart=on-failure\\n\\n[Install]\\nWantedBy=multi-user.target" > /etc/systemd/system/train-schedule.service
    /usr/bin/systemctl daemon-reload
    mkdir -p /opt/train-schedule
    chown root:train-schedule /opt/train-schedule
    chmod 775 /opt/train-schedule/
    yum -y install nodejs unzip

    I also went ahead and added that to video description so it's a little more clear in the future for other students. Thanks for your question!

  • post-author-pic
    Pradeep E
    11-12-2018

    I'm having issues with these steps with permission ID

    [user@pradeepe2 ~]$ sudo echo "deploy:jenkins" | sudo chpasswd

    [user@pradeepe2 ~]$ sudo usermod -a -G train-schedule deploy

    usermod: group 'train-schedule' does not exist

    [user@pradeepe2 ~]$ sudo groupadd train-schedule

    [user@pradeepe2 ~]$ sudo usermod -a -G train-schedule deploy

    [user@pradeepe2 ~]$ sudo echo "deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop train-sched ule" >> /etc/sudoers

    -bash: /etc/sudoers: Permission denied

    [user@pradeepe2 ~]$ sudo echo "deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop train-schedule" >> /etc/sudoers -bash: /etc/sudoers: Permission denied

    [user@pradeepe2 ~]$ sudo echo "deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop train-schedule" >> sudo /etc/sudoers

    [user@pradeepe2 ~]$ visudo

    visudo: /etc/sudoers: Permission denied

    [user@pradeepe2 ~]$ sudo visudo

    visudo: /etc/sudoers.tmp unchanged

    [user@pradeepe2 ~]$ sudo visudo

    visudo: /etc/sudoers.tmp unchanged

    [user@pradeepe2 ~]$ cd /etc/systemd/system/train-schedule.service

    -bash: cd: /etc/systemd/system/train-schedule.service: No such file or directory

    [user@pradeepe2 ~]$ sudo /etc/systemd/system/train-schedule.service


  • post-author-pic
    Pradeep E
    11-12-2018

    Can you please help me with this issue?

Looking For Team Training?

Learn More