First Automation

There are basically 4 steps to start automating with sysopswork:

  1. Create a Master Key (done just once, after sysopswork installation)

  2. Register Object(s) (done once per object)

  3. Persist Encrypted Object Credentials (done once per object)

  4. Run Automation Script (as many times you need without repeating steps 1 through 3)

Before we start, let me briefly explain some key aspects of sysopswork automation:

  • The Master Key is the one password used to lock and unlock credentials when your automation script is running. ( more details @ Objects )

  • Object is any infrastructure component you connect to implement commands, such a Linux OS, a network device, etc. ( more details @ Objects )

  • The Automation Script is the set of instructions you provide to sysopswork to automate implementations. Once the script is provided, sysopswork takes care of the rest. ( more details @ Automation Script )

Preparation

For this automation, we will implement a web server (using nginx) in an instance of Ubuntu Linux. If you don’t have a Linux machine (either physical or virtual) ready to use, below you can find easy step-by-step instructions to quickly spin up one in Microsoft Azure free of charge (considering you don’t have an account yet past trial period or ran out of credits).

Notice that you can choose any other cloud provider, if you prefer. Or have the Ubuntu machine running on a virtual machine or a bare metal physical box.

To create a free account on Microsoft Azure, follow the steps below:

Step 1. Access Microsoft Azure at https://azure.microsoft.com/
Step 2. Click on button “Try Azure for free”.
Step 3. At next page, click on “Start free”.
Step 4. Sign in to Microsoft (if you don’t have an account, you can create one).
Step 5. At Create your Azure free account, enter your profile information.
Step 6. Enter your credit card or debit card information. You won’t be charged for the Ubuntu VM we will create for this instruction throughout the period that Microsoft gives you credit for that resource.

After you click on sign up, Microsoft will let you know once your account is ready to be used.

If you got a page with the message “You’re ready to start with Azure”, click on “Go to the Azure portal”.

Now, we will create an Ubuntu VM on Microsoft Azure with the following steps (the options used below consider you are using a new account. If that is not the case, adjust accordingly):

Step 1. Once you logged into your Microsoft Azure account, at the Azure portal site, click on the search page at the top and type “virtual machine”. You must see an option “Virtual machines”. Click on it.

Step 2. Look for a button “Create”, and click on it, then select “Azure virtual machine”.

Step 3. At page “Create a virutal machine”, at section “Project details”, leave both “Subscription” and “Resource group” as is.

Step 4. At section “Instance details”, enter a Virtual machine name. In my case, I used “sysopswork-test”. Select the Region closest to you, and leave the other options as is. Ensure that the image selected is Ubuntu Server, and at the end it mentions (free services eligible). Ensure it has the same (free services eligible) mention at option Size. Leave the rest of the information as is, and click on “Next: Disks >” at the bottom of the page.

Step 5. We are not changing anything at this tab Disks. Simply click on “Next: Networking >” at the bottom of the page.

Step 6. At tab Networking, section “Network interface”, on option "Select inbound ports", select both "HTTP (80)" and "SSH (22)". Also look for “Delete public IP and NIC when VM is deleted” and check the box. Now, click on “Review + create”.

Step 7. You will be provided with a price, but with the new account, Microsoft gives you credits to create this resource. You can double check the details of this creation, then click on button “Create” at the bottom of the page.

Step 8. You are supposed to be prompted with a modal “Generate new key pair”. Click on “Download private key and create resource”.

Azure will take some time to create the Linux VM. Wait until you receive a confirmation that the deployment succeeded and is complete.

Step 9. If you are at the deployment page, click on “Go to resource” button.

Step 10. At the Virtual machine page you created, you must find the Public IP address that was assigned by Azure to your VM. Take note of that IP address.

Before we proceed with sysopswork, it is a good practice to test reachability to the object (in this case the Ubuntu machine) that we are going to automate.

At Step 8, a key file (with extension .pem) has been downloaded to your computer. Locate this file (likely to be at your user’s Downloads directory), and move it to sysopswork directory. Rename it to “key.pem” to follow the examples. Open your Command Prompt (on Windows) or Terminal (on macOS or Linux), and navigate to sysopswork directory. If you computer is running macOS or Linux, enter the following command (not applicable to Windows):

chmod 400 key.pem

Now, try to connect to the Ubuntu machine by running the following command (replace a.b.c.d by the Public IP address you took note from Step 10):

ssh -i key.pem -l azureuser a.b.c.d

Once connected to the Linux VM shell prompt, just leave the SSH session it with:

exit

After you run the automation, we provide instructions to delete this virtual machine at the very bottom of the page. Don’t do it, until you complete with the tests.

Running the First Automation

Assuming you already downloaded sysopswork and unzipped the file, and that you also have your Ubuntu Linux ready to be used (as explained on previous section). You need to have the IP address of the Ubuntu Linux in hand when registering the object.

Step 1. Download the automation script file from https://sysopswork.com/templates/first_script.zip, unzip the file and move the script file “first_script.txt” to sysopswork main directory. Check the content of the file to familiarize yourself with some of sysopswork instructions.

Step 2. Open the Command Prompt (on Windows) or Terminal (on macOS or Linux).

Step 3. Navigate to sysopswork main directory.

Step 4. From Windows Command Prompt, to create a Master Key, run:

sysopswork -K

Or from macOS/Linux Terminal, to create a Master Key, run:

./sysopswork -K

Step 5. From Windows Command Prompt, register the Ubuntu Linux as an object by using:

sysopswork -o ubuntu

Or from macOS/Linux Terminal, register the Ubuntu Linux as an object by using:

./sysopswork -o ubuntu
Note: we picked the name “ubuntu” but you can choose another name.

Step 5.1. Enter the IP address of Ubuntu Linux. It has to be the one you can reach directly from your computer.
Step 5.2. Enter access method of Ubuntu Linux. As we are going to use SSH, you just need to hit Enter, as SSH is the default access method.
Step 5.3. Enter login mode of Ubuntu Linux. If you are using a key (usually the case on Azure and other cloud providers), then enter key and hit Enter. If you are using username and password, you can hit Enter, as this is the default login mode.
Step 5.4. For the next two inputs, just hit Enter as they are optional and we will use the default values ( more details are provided @ Objects ).

Step 6. From Windows Command Prompt, persist Ubuntu Linux credentials with the command:

sysopswork -c ubuntu

Or from macOS/Linux Terminal, persist Ubuntu Linux credentials with the command:

./sysopswork -c ubuntu
Step 6.1. First, you need to enter the Master Key you created at step 4.
Step 6.2. Then, you will provide the credentials used to authenticate to this object. And that depends on the login mode used. If you followed the instructions to create an Ubuntu VM on Microsoft Azure, when prompted to enter the username, type azureuser, and when asked to enter the key file path, simple enter the key filename key.pem, considering the file is located at sysopswork main directory.

Now we are ready to run the automation script.

Step 7. From Windows Command Prompt, run the sysopswork command and indicate which automation script to use:

sysopswork first_script.txt

Or from macOS/Linux Terminal, run the sysopswork command and indicate which automation script to use:

./sysopswork first_script.txt
Wait until you receive the message “Automation Complete. Implementation Applied!”.

Step 8. You can test your automation by opening your Internet browser and entering http://a.b.c.d (by replacing a.b.c.d wit your Ubuntu IP address). You must see the nginx Welcome page.

That’s it! You ran your first sysopswork automation! Now you can explore what sysopswork can do for you throughout the next pages.

Post Automation

If you provisioned an Ubuntu VM using the Microsoft Azure example we provided, below are the steps to delete it once you are done experimenting with it:

Step 1. Open your Internet browser and access Microsoft Azure at https://portal.azure.com/
Step 2. Login using your credentials.
Step 3. If you don’t see the option “Virtual machines” at the portal home page, click on the search bar at the top and type “virtual machine”, then click on “Virtual machines”.
Step 4. You must see the VM you created at the Virtual machines page. Select it, by clicking on the checkbox at left hand side of the VM, then click on “Delete”.
Step 5. At the confirmation panel, type “yes”, then click on “Delete” button at the bottom of the page.

Once the VM is deleted, it will no longer show at the Virtual machines page.