PowerWire.eu

Independent IBM i, AIX and Linux news and tech tips for Europe and beyond

  • Home
  • News
  • Technical Articles
    • IBM i
    • AIX
    • Linux
    • VIOS
  • Subscribe
  • About Us
  • Contact Us
  • Advertise with PowerWire.eu

An Ansible Environment Setup

July 5, 2022 by Andy Youens 1 Comment

Firstly, thank-you to all those who attended my Ansible workshop and presentation of Visual Studio Code at the i-UG conference at Northampton in June.  It was great to be back presenting and meeting up with friends.

This article is related to this event.

The Power servers for the event, were kindly provided by Rowton IT They arranged four IBM i partitions for me to show all the features of Ansible.

To facilitate the workshop, I didn’t want to waste precious time setting up the servers, so Ansible to the rescue!

For each of the four partitions, I had to create the following;

Set the default PASE shell to be the BASH shell.

Then for a list of ten users, setup the following;

  1. Create a user profile, additionally setting the home directory and current library
  2. Create a user library, called the name of the user just created
  3. Create a home directory on the IFS
  4. Create a sub-directory, called Ansible off their home directory
  5. Create a sub-directory, called .ssh off their home directory
  6. Create a empty authorized_keys file in the users home .ssh directory
  7. Set the authority on the home directory
  8. Set the authority on the .ssh directory
  9. Create an empty .profile file in the users home directory
  10. In the .profile file, write entries to setup the Open Source path and a default prompt
  11. Set the authority on the authorized_keys file

As you can see, many steps to perform on the four partitions, lots of scope for errors and typo’s!

Due to the restrictions of using loops with Ansible, I split the environment create into two separate playbooks.

The first playbook is shown in the figure below.

Steps are as follows

  1. Description of the playbook, use for documentation purposes
  2. Run the playbook over all the IBM I partitions
  3. List of users to create
  4. Set the default PASE shell for all users
  5. Looping through all the users in step 3, call the playbook ibmi_iug1 with a parameter of the user

Now onto the second playbook, which is doing all the work.

This is shown in the figure below.

Let me explain the stages of this playbook.

  1. A quick debug message to show the user name being passed from previous playbook.  Just for informational purposes only.
  2. Create a user profile using the name of the user being passed
  3. Create a library with the user name
  4. Create a home directory for the user name
  5. Create an Ansible directory for the user
  6. Create a .ssh directory
  7. Create an authorized_keys file on the IFS for the user
  8. Set authority of the home directory for the user
  9. Set the authority of the .ssh directory
  10. Set the authority of the authorized_keys
  11. Create an empty .profile file for the user
  12. Set the profile to use a path for the open-source tools and also set the BASH prompt

Let me run the playbook, and show the steps it goes through (For space saving, I’ve restricted it to only run for one user).

All looks good!

Conclusion

Hopefully, this example shows how easy it is to use Ansible to create environments, no typos, or missing steps.

All the examples I have written for this article, and previous ones, can be found on my open-source repository on GitHub, which can be found at https://github.com/formaserve/f_Learning

The two playbooks used throughout this article are called https://github.com/FormaServe/f_Learning/blob/master/Ansible/ibmi_iug.yml

If you have any questions, either on this article, or anything else on the IBM i, use the comments below, or send me a message on twitter @AndyYouens

Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems with over 40 years IBM midrange experience. 

IBM Champion

Filed Under: IBM i, News, Technical Articles Tagged With: Andy Youens, IBM i, IBM Power Systems

Comments

  1. Mike R says

    July 6, 2022 at 9:19 am

    Brilliant!

    Yet another use for this flexible tool.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Free monthly newsletter signup

News

A screen a story – Not our problem anymore

Last week I ran into an issue, which did teach me something new about the command WRKPRB. After checking a … [Read More...]

Raspberry Pi and Machine Learning

In my last article, I demonstrated how I used Machine Learning on the Raspberry Pi to determine if a … [Read More...]

Shield Advanced Solutions – new Messaging and Monitoring solutions

September 2022 – Toronto As Shield Advanced Solutions celebrates the significant milestone, 25 years of … [Read More...]

More articles from this section

Quick Links

  • Advertise
  • Subscribe

Follow Us…

  • Email
  • LinkedIn
  • Twitter

Search This Website

Copyright © 2023 · Cue Communications · All Rights Reserved

Log in