ansible-devops icon indicating copy to clipboard operation
ansible-devops copied to clipboard

Documentation enhancement for OneClick Installer

Open ReneOro97 opened this issue 1 year ago • 0 comments

Reference link

OneClick Installer Procedure: https://ibm-mas.github.io/ansible-devops/playbooks/oneclick-core/#oneclick-install-for-mas-core

Summary

After finishing up the installation for MAS with Ansible Playbook (ibm.mas_devops.oneclick_core), MAS was installed successful on cluster and I was provided with Admin Dashboard URL and the credentials. However, trying to access to it, results in a page load hanging. The issue seems to be similar as the one described in this IBM Support link: https://www.ibm.com/support/pages/ibm-maximo-application-suite-initial-setup-page-does-not-load Only difference is that since the OneClick Installer already configures all prerequisites, I'm prompted directly to the admin dashboard. I was able to sort the issue by following the steps described in the[ IBM Support site|https://www.ibm.com/support/pages/ibm-maximo-application-suite-initial-setup-page-does-not-load] with the only difference that for the api link, I had to remove the "apps" section. Instead of https://api/.<instance_name>.apps..com/ should be https://api/.<instance_name>..com.

Recommended changes:

A possible enhancement to the documentation for OneClick Installer docs could include either the steps for sorting this issue or the IBM Support reference link.

A similar approach is also documented in https://www.ibm.com/docs/en/mas-cd/continuous-delivery?topic=configuring-setting-up-maximo-application-suite:

Enable login for Maximo Application Suite self-signed certificates.
If you are using self-signed certificates in a development or test environment, you must manually enable login by using either of the following methods:
Download the certificates from the cluster and add them to your local certificate manager.
In your browser, go to the Maximo Application Suite API URL: https://api.<mas_domain>/ and then accept the certificate security risks. After you accept the risks, an AIUC01999E error is displayed. This message is expected. You can now continue with the setup process.

But could be useful to add a similar note in the OneClick Installer to specify that whenever using self certificates you should go to the MAS API to accept the security risk.

ReneOro97 avatar Jan 24 '24 21:01 ReneOro97

the ansible provisioner works perfectly with the ansible lxd connection plugin community.general.lxd

itoffshore avatar Apr 03 '22 17:04 itoffshore

@itoffshore can you show me a small example. Because the example above doesn't work.

keestux avatar Apr 03 '22 17:04 keestux

@keestux - use HCL2 style templating (not json as you are above) - I put an example on Stack Exchange - with values hardcoded.

I now configure various variables which you will see in the HCL example below. Ultimately you want to aim for nothing hardcoded in your HCL template.

basic ansible configuration:

# ansible/inventory.yml

default:
  hosts:
    127.0.0.1:
      ansible_python_interpreter: "/usr/bin/python3"
      ansible_connection: lxd

# ansible/playbook.yml

---
 - name: Install Packages
   hosts: default
   gather_facts: no

   tasks:
     - name: Install ubuntu-base packages
       when: build_template == "ubuntu-base"
       apt:
         pkg:
         - curl

HCL template

source "lxd" "master" {
  
  image = "${var.lxd_remote}:${local.final_img}"
  output_image = "${local.output_image}"

  publish_properties = {
        description = "IAC image: ${local.output_image}"
  }
}


build {
  # using vars for sources triggers double build errors
  # this references the above source block
  sources = ["source.lxd.master"]

# install python3 (either Packer shell provisioner or Ansible)

...

# configure container
  provisioner "ansible" {
        user = "root"
        playbook_file = "${path.cwd}/ansible/playbook.yml"
        inventory_file = "${path.cwd}/ansible/inventory.yml"
        ansible_env_vars = [
                "ANSIBLE_NOCOLOR=True",
        ]

        # NB: ansible_host set here
        # also an example of passing variables to ansible & running verbosely
        extra_arguments = [ "--extra-vars=build_template=${local.build_template} ansible_host=packer-${source.name}", "-vvv" ]
  }


# shell provisioners
...

# post processors
...

}

My file structure looks like:

├── ansible
│   ├── inventory.yml
│   ├── playbook.yml
├── locals.pkr.hcl
├── set.variables.pkr.hcl
├── template-lxd-master.pkr.hcl
├── var.alpine-base.pkrvars.hcl
├── var.alpine-lxd.pkrvars.hcl
├── var.ubuntu-base.pkrvars.hcl
└── var.ubuntu-k3s.pkrvars.hcl

In this way I can run builds with specific variables set e.g:

packer validate -var-file=var.ubuntu-base.pkrvars.hcl .
packer build -only lxd.master -var-file=var.ubuntu-base.pkrvars.hcl .

NB: the dot at the end of the above 2 commands to source all the variable files


Start with the hardcoded example on Stack Exchange - read the HCL docs completely a few times so you can understand the type of logic that can be constructed. Also helpful was looking at https://discuss.hashicorp.com/

itoffshore avatar Apr 03 '22 19:04 itoffshore

Thanks for the help.

Well, I wanted to start with a (small) hardcoded example. But the one on Stack Exchange is using a shell provisioner. And I want to see something working with ansible. On the other hand the example above is giving an idea how to set it up properly with multiple HCL files. I need some help with the extra_arguments, perhaps hardcoded.

keestux avatar Apr 03 '22 21:04 keestux

Back to why my original example didn't work. The essential part is that (intermediate) container is named: packer-<name-from-build-config>. In my example (above) that should have been packer-lxd-focal, not localhost. This name has to be given in the inventory.

So the complete example (in json format):

{
  "builders": [
    {
      "type": "lxd",
      "name": "lxd-focal",
      "image": "ubuntu:focal",
      "output_image": "focal-apache2",
      "publish_properties": {
        "description": "Trivial repackage ubuntu:focal+apache2 with Packer"
      }
    }
  ],
  "provisioners": [
      {
        "type": "ansible",
        "playbook_file": "ansible/playbook.yml",
        "inventory_file": "ansible/inventory.yml"
      }
  ]
}

Ansible inventory ansible/inventory.yml:

default:
  hosts:
    packer-lxd-focal:
      ansible_connection: lxd

Ansible playbook ansible/playbook.yml:

---
- name: Install Packages
  hosts: default
  gather_facts: yes

  tasks:
  - name: Install some packages
    ansible.builtin.apt:
      name:
      - apache2
      state: present

Final word for @itoffshore . The HCL format is indeed a better choice for packer configs. But that did not help to figure out what was wrong in the first place.

keestux avatar Apr 06 '22 20:04 keestux

Glad you got it working ;o)

As shown & NB: in my example:

# NB: ansible_host set here
# also an example of passing variables to ansible & running verbosely
extra_arguments = [ "--extra-vars=build_template=${local.build_template} ansible_host=packer-${source.name}, "-vvv"" ]

I use a computed value for ansible_host (you have hardcoded it into the ansible inventory). If you have more than one template you will have to hardcode the hostname multiple times in the inventory.

itoffshore avatar Apr 06 '22 20:04 itoffshore

Sure. But it was totally unclear to me that this NB was the key point. (Plus, I think there is a syntax error with the quotes in your extra_arguments.)

keestux avatar Apr 06 '22 20:04 keestux

ansible plugin is not working for me. Same problem when building LXC or LXD images using LXC and LXD ansible connection respectively.

2022/07/08 10:49:54 ui: ==> lxd.alpine-base: Provisioning with Ansible...
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: panic: interface conversion: interface {} is nil, not string
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: 
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: goroutine 116 [running]:
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-ansible/provisioner/ansible.(*Provisioner).Provision(0xc000219600, {0xc00013e000, 0x0}, {0x107e020, 0xc0007aa180}, {0x107d8d8, 0xc0007ae0a0}, 0xc00050c000)
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: 	github.com/hashicorp/packer-plugin-ansible/provisioner/ansible/provisioner.go:550 +0xac5
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*ProvisionerServer).Provision(0xc0002b2080, 0xc000704580, 0x1)
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: 	github.com/hashicorp/[email protected]/rpc/provisioner.go:88 +0x1e7
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: reflect.Value.call({0xc000134900, 0xc00038a088, 0x13}, {0xe72828, 0x4}, {0xc000727ef8, 0x3, 0x3})
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: 	reflect/value.go:556 +0x845
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: reflect.Value.Call({0xc000134900, 0xc00038a088, 0xc0003ae000}, {0xc000899ef8, 0x3, 0x3})
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: 	reflect/value.go:339 +0xc5
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: net/rpc.(*service).call(0xc0002b20c0, 0xc000032630, 0x0, 0xc0000347a0, 0xc000396200, 0x5ec285, {0xce2ae0, 0xc000704580, 0x5ec206}, {0xcecd20, ...}, ...)
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: 	net/rpc/server.go:377 +0x239
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: created by net/rpc.(*Server).ServeCodec
2022/07/08 10:49:54 packer-plugin-ansible_v1.0.3_x5.0_linux_amd64 plugin: 	net/rpc/server.go:474 +0x405
2022/07/08 10:49:54 /root/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.0.3_x5.0_linux_amd64: plugin process exited
2022/07/08 10:49:54 [INFO] (telemetry) ending ansible

rnalrd avatar Jul 08 '22 11:07 rnalrd