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

Documentation for general installation in containerized environments #3355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

me-coder
Copy link

@me-coder me-coder commented Oct 2, 2024

The CFEngine installation guide is missing out on containers.
This PR is an attempt to project the capability of CFEngine with containers (using ubi9-init images).

There are a few limitations due to the nature of CFEngine (requires privileged mode and container is required to have systemd, which need initialization with /var/sbin/init).
However, it still gives a good ability to test CFEngine in containerized environments in full capacity, without the need to have a bulky multi VM setup.

Hope the moderator team finds this useful and decides to integrate it into the docs.

@me-coder me-coder force-pushed the master branch 5 times, most recently from fa645e7 to 5e7da00 Compare October 2, 2024 19:18
@me-coder
Copy link
Author

me-coder commented Oct 2, 2024

I am unable to figure out the reason for failure of check with:
Run markdowner.py on all markdown files and see if there are changes / check (pull_request)

Any help to deal with this cryptic error is appreciated.

@olehermanse
Copy link
Member

I am unable to figure out the reason for failure of check with:
Run markdowner.py on all markdown files and see if there are changes / check (pull_request)

Any help to deal with this cryptic error is appreciated.

Your files have extra spaces in them, at the ends of multiple lines.
Change your editor to automatically trim trailing whitespace for you, or run the command as suggested;

python3 .github/workflows/markdowner.py ./getting-started/installation/general-installation/installation-community-containerized.markdown

That will edit the file, removing those extra unnecessary spaces.
(Afterwards you will need to add and commit those changes - git add -p ; git commit).

@me-coder
Copy link
Author

me-coder commented Oct 3, 2024

I am unable to figure out the reason for failure of check with:
Run markdowner.py on all markdown files and see if there are changes / check (pull_request)

Any help to deal with this cryptic error is appreciated.

Your files have extra spaces in them, at the ends of multiple lines. Change your editor to automatically trim trailing whitespace for you, or run the command as suggested;

python3 .github/workflows/markdowner.py ./getting-started/installation/general-installation/installation-community-containerized.markdown

That will edit the file, removing those extra unnecessary spaces. (Afterwards you will need to add and commit those changes - git add -p ; git commit).

The extra spaces (particularly ^.+<space><space>$ was required for newline as per the markdown requirements.
However, that has been replaced by </br> now and seems to have worked.
Thanks for the suggestion.

@me-coder
Copy link
Author

me-coder commented Oct 3, 2024

@olehermanse,
I've made this change to take care of such situations, if encountered by other contributors:
c9719c9

Hope that's fine.

@olehermanse
Copy link
Member

The extra spaces (particularly ^.+$ was required for newline as per the markdown requirements.

What requirements? This is not required.

However, that has been replaced by
now and seems to have worked.

No, remove these, they are not necessary.

I've made this change to take care of such situations, if encountered by other contributors:
c9719c9

Hope that's fine.

No, that change is not correct, remove it. We want to strip trailing whitespace. You don't need trailing whitespace nor html tags (</br>) to write this tutorial.

Bootstrap cfengine-host to cfengine-hub:

```command
$ docker exec cfengine-host bash -c "/usr/local/sbin/cf-agent --bootstrap ${CFENGINE_HUB_IP}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$ docker exec cfengine-host bash -c "/usr/local/sbin/cf-agent --bootstrap ${CFENGINE_HUB_IP}"
docker exec cfengine-host bash -c "/usr/local/sbin/cf-agent --bootstrap ${CFENGINE_HUB_IP}"

Copy link
Member

Choose a reason for hiding this comment

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

Humm, this didn't work for me.

docker exec cfengine-host bash -c "/usr/local/sbin/cf-agent --bootstrap ${CFENGINE_HUB_IP}"
bash: line 1: /usr/local/sbin/cf-agent: No such file or directory

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, that's because we miss to read

Rest of the installation steps remain the same as for cfengine-hub.

I've removed this and added granular steps instead.

After the fix

cfengine$ docker exec cfengine-host bash -c "/usr/local/sbin/cf-agent --bootstrap ${CFENGINE_HUB_IP}"
  notice: Bootstrap mode: implicitly trusting server, use --trust-server=no if server trust is already established
  notice: Trusting new key: MD5=e5da40ee8037819f033e972d0fa24bcf
R: Bootstrapping from host '172.17.0.2' via built-in policy '/var/cfengine/inputs/failsafe.cf'
R: This autonomous node assumes the role of voluntary client
R: Updated local policy from policy server
R: Triggered an initial run of the policy
R: Restarted systemd unit cfengine3
  notice: Bootstrap to '172.17.0.2' completed successfully

While working on this part I realized that the Dockerfile and docker compose based approach is much efficient and faster as the installation happens only once.
However, for understanding sake, we should maintain this approach for deploying containers individually as well.

Copy link
Member

@nickanderson nickanderson left a comment

Choose a reason for hiding this comment

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

@me-coder thank you for this contribution. Overall it's quite a nice addition. Looking forward to having this in the docs.

sorting: 80
---

These instructions describe how to download and install the latest version of CFEngine Community in a docker containerized environment using pre-compiled rpm packages for ubi9 images.
Copy link
Member

Choose a reason for hiding this comment

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

I don't know of any other place we reference ubi images. Might be worth some description of what a ubi9 image is.

Red Hat Universal Base Images (UBI) are OCI-compliant container base operating system images with complementary runtime languages and packages that are freely redistributable.

Copy link
Author

Choose a reason for hiding this comment

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

Bootstrap cfengine-host to cfengine-hub:

```command
$ docker exec cfengine-host bash -c "/usr/local/sbin/cf-agent --bootstrap ${CFENGINE_HUB_IP}"
Copy link
Member

Choose a reason for hiding this comment

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

Humm, this didn't work for me.

docker exec cfengine-host bash -c "/usr/local/sbin/cf-agent --bootstrap ${CFENGINE_HUB_IP}"
bash: line 1: /usr/local/sbin/cf-agent: No such file or directory

Start service cfengine-demo

```command
$ docker compose -f compose.yaml --verbose up -d
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$ docker compose -f compose.yaml --verbose up -d
docker compose -f compose.yaml --verbose up -d

Copy link
Member

Choose a reason for hiding this comment

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

I get an error running this.

validating /tmp/test/compose.yaml: services.cfengine-host.depends_on must be a list

Copy link
Author

@me-coder me-coder Oct 4, 2024

Choose a reason for hiding this comment

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

Yes, there was an indentation issue in the config.yaml. I've fixed it.
Also, added a linting step for Dockerfile and compose.yaml to capture such issues better,

@@ -2,7 +2,7 @@
layout: default
title: Installing Enterprise on CoreOS
Copy link
Member

Choose a reason for hiding this comment

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

@olehermanse Perhaps this should be re-titled to Installing Enterprise using disk image Or actually, maybe we need to drop this page completely. I don't see that we are still publishing a disk image since CoreOS is died (and now it's resurrected under Fedora https://fedoraproject.org/coreos/ ).

@me-coder
Copy link
Author

me-coder commented Oct 4, 2024

Hi @olehermanse, @nickanderson,
Thank you for the detailed review.

I made the suggested changes and also a few enhancements to the document and force pushed it as a amended single commit.
I'm not sure if the suggested commits were supposed to be incorporated or were just markers for the review suggestions. (unaware of the rules being followed for this project).

I submitted a single commit as I always feel it's cleaner, could be fast-forwarded and there were changes which I could easily edit as a batch in VSCode editor.

Kindly re-consider the review with the applied changes.

- @me-coder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants