Tuesday, July 5, 2022

Disable DNF Dragora on Fedora

Synopsis

Being a person that likes to manage updates on my own schedule, rather than being reminded, and also not liking processes running that don't need to be, I searched around to find how to disable the DNF Dragora application.

This application is a Fedora GUI application and the background task is not a systemd task, but an autostart task.

Locations

Autostart directories are located in 1 of 2 places:
  • /etc/xdg/autostart
  • $HOME/.config/autostart
The first is system wide since it is under /etc, where as the other is personal to you and things that you have decided you want to be running once you've logged into the GUI.

You should always start by checking your home version first and renaming the file if you're not sure if you want it stopped, or deleting it if you want it permanently gone.  In most cases you can also deal with start up applications through gnome-tweaks.

Finding DNF Dragora

Having check my home directory $HOME/.config/autostart for dnfdragora as follows:

grep -ri drag ~/.config/autostart

I found no files containing the dnfdragora command.

Locating other autostart folders with:

sudo find / -name autostart

We find the /etc/xdg/autostart folder.

Using the following grep command we find the following file:

grep -ri drag /etc/xdg/autostart

/etc/xdg/autostart/org.mageia.dnfdragora-updater.desktop

Disabling DNF Dragora

To disable it (rather than removing it, if you change your mind) you simply do the following:

cd /etc/xdg/autostart

mv org.mageia.dnfdragora-updater.desktop org.mageia.dnfdragora-updater.desktop.old

Simply making sure that .desktop is not the last part of the file name will prevent the file being seen.

Log out and back in and DNF Dragora should no longer be there.

Friday, July 1, 2022

How to simply build a Jenkins server and Agent

Having been working on another DevOps Academy it was surprising with the research that the students did on how to build a Jenkins server with Agent, how complicated most people made it.

This example is based on using AWS with 2 EC2 instances, but would work on-prem and other clouds.

Steps to build

1. Create 2 Ubuntu instances both Medium

  • 1 is Controller
  • 1 is the Agent
  • Settings
    • t2.medium
    • 20GB disk
    • Ubuntu image
      • Select or create a security group (e.g. jenkinssg) that has the following inbound ports
        • 8080
        • 22
        • 8200

2. Install Jenkins on the controller

    • ssh onto the Jenkins controller
    • sudo apt update # It's Ubunutu after all
    • sudo apt -y install openjdk-11-jdk # Install Java, Jenkins needs it
    • wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
    • sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
    • sudo apt update
    • sudo apt install jenkins
    • sudo cat /var/lib/jenkins/secrets/initialAdminPassword   # Get the login password

3. Web browser

    • Point your web browser at http://yourPublicIPforInstance:8080
      • Paste in the text from the file
      • Click Continue button
    • Click Install suggested plugins
    • Fill in the form to create the main Jenkins user
      • Username: admin
      • Password: secret123
      • Confirm password: secret123
      • Fullname: Administrator
      • E-mail address: root@nowhere.com
    • Click Save and Continue button
    • Change the IP address to the Private IP address of your Jenkins instance
      • Leave the http:// and the :8080/
    • Click Save and Finish button
    • Click Start using Jenkins button

4. Configuring Jenkins to see the new node to be the agent

    • After doing step 3 you should be logged in as Administrator
      • If not log in using admin and the password you set
    • Click Manage Jenkins in the left menu
    • Click Manage Nodes and Clients
    • Click New Node in the new menu
    • Set the Node name to Worker1
    • Select Permanent Agent
    • Click Create button
    • New screen
      • Number of executors: 2
      • Remote root directory: /home/ubuntu
      • Labels: all
      • Leave all other as default
      • Click Save
    • The worker node will show as not connected
    • Click on Worker1 link
    • You'll notice an error message
      • JNLP agent port is disabled and agents cannot connect this way. Go to security configuration screen and change it.
      • Click the link Go to security configuration screen and change it.
      • Scroll down to Agents
        • Select Fixed
        • Set the Port to 8200 (This is already allowed by jenkinssg)
      • Scroll to the bottom and click the Save button
    • Click Manage Nodes and Clients
    • Click Worker1
    • Right click the blue agent.jar link and Copy link address

5. Now ssh on to your Worker/Agent instance

    • sudo apt update
    • sudo apt -y install openjdk-11-jdk
    • wget http://52.213.211.75:8080/jnlpJars/agent.jar
      • Where the http:// link is pasted from the Copy link address
    • On the Jenkins web page copy the 2nd box echo line
      • Paste this line into the terminal of the Worker/Agent ssh session
    • On the Jenkins web page copy the 2nd box java -jar line
      • In the terminal of the Worker/Agent ssh session
      • Type the word   nohup
        • Then paste the java -jar line after this
        • Type a space and then   &    at the end of the line
      • e.g.
        • nohup java -jar agent.jar -jnlpUrl http://172.31.16.36:8080/computer/Worker1/jenkins-agent.jnlp -secret @secret-file -workDir "/home/ubuntu" &

6. Back to the Jenkins web site

    • Click Back to List if you are in the Agent Worker1 screen
    • or
    • Click Dashboards top left of the page
      • Click Manage Jenkins
      • Click Manage Nodes and Clouds
    • Note your agent is now connected

NOTE:
This configuration doesn't create a service to start the agent on reboot, but is purely an example to get it running.  To make the agent a proper service you would need to create the appropriate file in /etc/systemd/system (call it jenkins-agent.service) or for older systems the service script in /etc/init.d.