In this post, I will create a new life-cycle environment paths for the Operations organization that includes life-cycle environments named Deveopment, QA, and Production.

Let’s list the current life-cycle environment for Operations organization.

[root@foreman ~]# hammer lifecycle-environment list --organization Operations
---|---------|------
ID | NAME    | PRIOR
---|---------|------
6  | Library |
---|---------|------

When we create our first environment, we’ll need to use the ID of the Library, which is 6 in this case. Alternatively, we can just “Library” as the argument to --prior option.

I’m going to use hammer to add the Development environment.

[root@foreman ~]# hammer lifecycle-environment create \
--organization Operations \
--name Development \
--description Development \
--prior Library
Environment created.

Here is the result so far.

[root@foreman ~]# hammer lifecycle-environment paths --organization Operations
----------------------
LIFECYCLE PATH
----------------------
Library >> Development
----------------------
[root@foreman ~]# hammer lifecycle-environment list --organization Operations
---|-------------|--------
ID | NAME        | PRIOR
---|-------------|--------
7  | Development | Library
6  | Library     |
---|-------------|--------

We can continue with our task to add the QA environment to the same life-cycle environment path as Development.

[root@foreman ~]# hammer lifecycle-environment create \
--name QA --label QA --organization Operations \
--description QA --prior-id 7
Environment created.

Finally, add the Production environment to the same life-cycle environment path as Development and QA.

[root@foreman ~]# hammer lifecycle-environment create \
--name Production --description Production \
--label Production --prior QA \
--organization Operations
Environment created.

We can view the available life-cycle environment paths with this command.

[root@foreman ~]# hammer lifecycle-environment paths --organization Operations
------------------------------------------
LIFECYCLE PATH
------------------------------------------
Library >> Development >> QA >> Production
------------------------------------------

Now I start to understand why many people prefer to use hammer CLI to manage their foreman/satellite servers.

Reference:

  • Chapter 2 - Managing Software Life Cycles of Student Workbook.