Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kogito-2195] Kogito examples with ansible automation #258

Open
wants to merge 41 commits into
base: main
Choose a base branch
from

Conversation

desmax74
Copy link
Contributor

@sterobin
Copy link

sterobin commented May 15, 2020

@danielezonca , @krisv , @ricardozanini , @radtriste , who should we add as dev reviewers and QE reviewers (if applicable) for this to get it worked in and approved for the examples? Max and I apparently don't have permissions to add reviewers officially.

Copy link
Contributor

@jiripetrlik jiripetrlik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@desmax74
Hello! Thank you for your PR. I've put the first review here. Unfortunately I was not able to test it because the setup is for Ubuntu/Debian. Can you please add setup also for some RedHat like systems such as Fedora?

Ansible scripts to automate creation of CRC cluster and the deploy of one of the Kogito examples with just one command line.

CRC 1.10.0, and Ansible must be installed.
No previous CRC setup (no /home/{user}/.crc folder), otherwise the create script will fail, delete .crc if you want run more than once the create playbook
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this optional. User may want to use his already CRC deployed cluster. It is probably not good to force user to remove all his previous CRC setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

### Install CRC
(If you haven't already installed)

Pre requisite on Debian/Ubuntu:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide version of Ubuntu and Debian on which you have tested these scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

```sh
sudo ansible-playbook ./playbook_etc_hosts.yaml
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide setup also for Fedora.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create two sections in the doc since is all for fedora and only the lib virt installation is the first step on ubuntu

tasks:

- name: install
shell: "sudo apt install qemu-kvm libvirt-daemon libvirt-daemon-system network-manager -y"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

- name: install
shell: "sudo apt install qemu-kvm libvirt-daemon libvirt-daemon-system network-manager -y"
become: yes
when: ansible_os_family == 'Debian'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check that os family is supported using assert module instead of silently skipping installation of libvirt libraries.
https://docs.ansible.com/ansible/latest/modules/assert_module.html#assert-module

Copy link
Contributor Author

@desmax74 desmax74 May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

- name: Copy Kogito cli
get_url:
url: "https://github.com/kiegroup/kogito-cloud-operator/releases/download/{{ kogito_tag }}/kogito-cli-{{ kogito_tag }}-linux-amd64.tar.gz"
dest: "/tmp/kogito-{{ kogito_tag }}-linux-amd64.tar.gz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again please create variable for this temporary destination with default value. Or you can also consider to use "tempfile" module. https://docs.ansible.com/ansible/latest/modules/tempfile_module.html#tempfile-module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok


tasks:

- name: Check api in hosts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't DNS reconfigured by CRC itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to check with the latest version, because with old version of crc without this manual addition on /etc/hosts the cluster was unreachable

kogito_tag: "0.10.0"
ram: "16384" #MB
libvirt_version: "4.4.3"
ip_on_etc_hosts: 192.168.130.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use this value which can probably change on different machine etc. It would be much better to use "virt" or "virt_net" modules to obtain info about IP address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

---
- name: Start CRC 1.10.0 and deploy Kogito Operator and CLI
hosts: localhost
gather_facts: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to explicitly run this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, was just to describe the version used, we could use a placeholder and print the version used instead to updated this on every update

---
- name: Install CRC
hosts: localhost
gather_facts: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this done by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, is disabled by default to save time, but to read the current user infos is needed

@jiripetrlik
Copy link
Contributor

@sterobin Hello I did the first QE review for this.

@desmax74
Copy link
Contributor Author

@jiripetrlik These scripts are developed and tested on Fedora 31, only the playbook_scripts is for ubuntu if is the system used.

@jiripetrlik
Copy link
Contributor

@desmax74 It seems to me that "playbook_libs.yaml" is developed for Ubuntu isn't it? And as libvirts setup is necessary for whole setup we probably need alternative for Fedora. Do you agree?

@desmax74
Copy link
Contributor Author

@jiripetrlik yep, only playbook_libs.yaml is for ubuntu, if isn't clear the description "Pre requisite on Debian/Ubuntu:
Install libvirt libs on Debian/Ubuntu only:" " I could change.
Libvirt was already present on Fedora iirc.

@jiripetrlik
Copy link
Contributor

@desmax74
I would suggest to install "dnf install @Virtualization" to be sure. Please use proper package module of Ansible to do that. Or check if libvirtd is running and in case that it does not install virtualization packages. To be honest don't know which packages are installed by default. But it may probably differ on Fedora type, such as desktop or server. Or it may be different for Fedora spins.

See documentation for Fedora virtualization packages: https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-virtualization/

Copy link
Contributor

@danielezonca danielezonca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR :)
Some comments

kogito-ansible/README.md Outdated Show resolved Hide resolved
kogito-ansible/playbook_crc.yaml Outdated Show resolved Hide resolved
kogito-ansible/playbook_create.yaml Outdated Show resolved Hide resolved
vars:
kogito_tag: "0.10.0"
ram: "16384" #MB
libvirt_version: "4.4.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this value hardcoded?

Copy link
Contributor Author

@desmax74 desmax74 May 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because is used in the path and you discover the version only when the crc is downloaded and unpacked, or readed from the lates json info

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've writed a version to use the latest kogito tag, but the 0.10.1 doesn't work because the cli and the operator aren't aligned (kogito 0.10.1 - kogito-cloud-operator 0.10.0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm I expect this could happen in the future too so is it possible to add a kogito-operator variable to support also this use case?

README.md Outdated Show resolved Hide resolved
kogito-ansible/README.md Outdated Show resolved Hide resolved
kogito-ansible/playbook_deploy.yaml Outdated Show resolved Hide resolved
kogito-ansible/playbook_create.yaml Outdated Show resolved Hide resolved
kogito-ansible/playbook_deploy.yaml Show resolved Hide resolved



## Ubuntu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this section actually different from the Fedora one?
They are really similar (the same?) from what I can see. Is it possible to create a single Fedora/Ubuntu section and just highlight different steps (if any).
This can reduce maintenance cost of this doc :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously only one section plus the ubuntu lib virt installation was present but at the reviewer seems a document for ubuntu deploy and asked a fedora version, for this reason you see explicit configurations for both systems

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree to have the instructions for Ubuntu and Fedora too but if they are the same just mention that the instructions are tested on both configuration instead of duplicate them :)

when: ansible_os_family == 'Debian'

- name: Install Virtualization on Fedora
shell: "sudo dnf install @virtualization -y"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Ansible DNF module instead https://docs.ansible.com/ansible/latest/modules/dnf_module.html#dnf-module

Something like this:
- name: Install Virtualization on Fedora
dnf:
name: "@Virtualization"
become: yes
when: ansible_os_family == 'RedHat'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@jiripetrlik
Copy link
Contributor

@desmax74
I've found two possible bugs when installing on fresh Ubuntu 20.04.

  1. In playbook "playbook_crc", "crc libvirt group" task. Crc can not be found because folder ".local/bin" did not exist before running Ansible script, To workaround this it is necessary to reinitialize terminal and run command manually "crc config set skip-check-user-in-libvirt-group true"

  2. In "playbook_create" in "Start CRC with 13312MB" task. I see the following error: "Failed to query DNS from host: lookup api.crc.testing: no such host"

@desmax74
Copy link
Contributor Author

@jiripetrlik

  1. Why not just simply create the folder as a pre-task ?

  2. I could re-apply kiegroup@654af19#diff-5ab00d684a07bbdf26507b898ba2a2ff

@jiripetrlik
Copy link
Contributor

@desmax74
ad 1, I've moved "Create .local/bin/" task to pre_tasks but without any effect. It is still necessary to login and logout to have crc command on PATH.
ad 2, I've tried to run "kogito-ansible/playbook_etc_hosts.yaml" before playbook_create but it failed with the following error "Failed to query DNS from host: lookup foo.apps-crc.testing: no such host". I think we need to find more general solution than adding lines to hosts file for each domain. Is CRC supported on Debian/Ubuntu?

@desmax74
Copy link
Contributor Author

In the Ubuntu 20.04 bashrc isn't present the PATH="$HOME/.local/bin
I'll change the script to change the bashrc to re add like the 19.10

Copy link
Contributor

@danielezonca danielezonca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 👍
@desmax74 can you please rebase from master to make the build green?

@desmax74
Copy link
Contributor Author

desmax74 commented Jun 9, 2020

@jiripetrlik dropped ubuntu until we found a workaround, please review

@jiripetrlik
Copy link
Contributor

@desmax74 Hello currently I'm getting following error on Fedora 32 : ""changed": true, "cmd": "crc setup", "delta": "0:03:00.977265", "end": "2020-06-16 10:31:41.176060", "msg": "non-zero return code", "rc": 1, "start": "2020-06-16 10:28:40.198795", "stderr": "level=fatal msg="Failed to start libvirt 'crc' network"", "stderr_lines"...

@jiripetrlik
Copy link
Contributor

@desmax74 It also seems that there are some commits unrelated to PR and PR check failed. Can you please rebase properly?

@domhanak
Copy link

domhanak commented Mar 1, 2024

@krisv @mdproctor @ricardozanini do you have any information about this?

@domhanak domhanak added the stale This label is for items that are stale with no activity for more than a month label Mar 1, 2024
@ricardozanini
Copy link
Member

I'd close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This label is for items that are stale with no activity for more than a month
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants