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

Fixing some plays/conf/readme in order to deploy from MAC OS #1758

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Forklift provides tools to create Foreman/Katello environments for development,
- [Additional Documentation](#additional-documentation)
- [Development Environment](#development-environment)
- [Using Playbooks and Roles Without Vagrant](#using-playbooks-and-roles-without-vagrant)
- [Python Venv for MacOS or Non Ansible Linux](#python-venv-for-macos-or-non-ansible-linux)
- [Credentials](#credentials)
- [Poor man's DNS a.k.a /etc/hosts](#poor-mans-dns-aka-etchosts)
- [Adding Custom Boxes](#adding-custom-boxes)
Expand Down Expand Up @@ -131,9 +132,34 @@ In case using Vagrant is not desired, ansible playbooks and roles from this repo
on test.example.com machine, where the dev env should be deployed
```sh
useradd vagrant
echo vagrant:redhat | chpasswd
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Author

Choose a reason for hiding this comment

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

I believe vagrant will deploy some key or information on the VM, in my case, I'm building a machine externally, so, once there are a bunch of plays using vagrant, I believe that keeping the user and setting the auth should be great, once I need to copy the ssh key to it. Anyway, I'm still testing the forklift with this env, passing --user root seems to work fine, but I'm not sure if we really need the vagrant user ... I believe yes.

Ps.: The ansible.cfg is using vagrant user as remote, so, not sure if we will connect as vagrant or if the play will connect as root and after that, will switch to the vagrant user.

Please, let me know if you are familiar with this process on forklift.

Thank you!
Waldirio

echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
```

#### Python Venv for MacOS or Non Ansible Linux

Here we can see the initial configuration, when creating the python virtual environment and preparing the setup (MACOS Users or Regular Linux with no ansible)
Copy link
Member

Choose a reason for hiding this comment

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

What if we introduce this virtual env method as it's own sub-section within this section to help users understand that a virtual env is an option?

Copy link
Author

Choose a reason for hiding this comment

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

Sounds like a plan, let me do it.

Thank you!
Waldirio

Copy link
Author

Choose a reason for hiding this comment

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

@ehelms please, let me know what you think.

Thank you!
Waldirio

```sh
/usr/local/bin/python3 -m venv ~/.venv/forklift
source ~/.venv/forklift/bin/activate
pip install --upgrade pip
pip install ansible
```
Note. Above, you can see `python3`, this is the standard for any x86 server running Linux. If you are using MacOS M1 or M2 with arm processors, then you should use `/usr/local/bin/python3-intel64` instead, just for the sake of compatibility with x86.
Copy link
Member

Choose a reason for hiding this comment

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

Do we care if it's compatible with x86? Does Ansible rely on any native libraries that aren't available on ARM?



Then you can clone forklift and move on
```sh
git clone https://github.com/theforeman/forklift.git
cd forklift
ansible-galaxy collection install -r requirements.yml
```

Now, you can share the ssh key with the server
```sh
ssh-copy-id [email protected]
```

Comment on lines +151 to +162
Copy link
Member

@ehelms ehelms Feb 6, 2024

Choose a reason for hiding this comment

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

Is this a repeat of previous steps in our documentation that is unspecific to the virtual env method? I am guessing that ansible-galaxy step is the unique one?

We could move everything else below this so that these steps are outside of the virtual env header

Copy link
Author

@waldirio waldirio Feb 7, 2024

Choose a reason for hiding this comment

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

ok, let's check how we can do this better. In the requirements, we can see

Vagrant - 2.2+ - Both the VirtualBox and Libvirt providers are tested
Ansible - 2.12+
[Vagrant Libvirt provider plugin](https://github.com/vagrant-libvirt/vagrant-libvirt) (if using Libvirt)
Virtualization enabled in BIOS

For a regular fedora, we can install the packages and it will work with no issues. As a mac user, trying to test this environment and set the best practices, it's not standard ansible via package, as well vagrant. Once virtualization it's not something that will works in a short term for this kind of processor, what I'm doing is, using the forklift to prepare the basic installation, using the plays that are already around, and installing the minimal as possible.

To achieve that, we can use virtual env, python3 is already standard on mac, that specific binary will keep the compatibility with x86 python modules, then internally we can just install ansible anv voila, we can proceed using the plays.

All the plays that we have atm will work with no problem? No idea, but I'll test! 😉

With that said, I'm recommending the venv just for the section below, for everyone else with fedora/rhel, it should not be a big deal, they could install the rpms and everything should be fine.

#### Python Venv for MacOS or Non Ansible Linux

Let me know what you think.
Waldirio

in forklift checkout
```sh
echo -e "[devel]\ntest.example.com" > inventories/local_inventory
Copy link
Author

Choose a reason for hiding this comment

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

Hi,

Here, there is no devel.yml, I'm not sure if this one was around before or not, but I didn't change it. I'll do a double check on all the plays on this folder. Just FYI.

Thank you!
Waldirio

Expand All @@ -142,6 +168,12 @@ ansible-playbook --private-key=~/.ssh/id_rsa --user root --inventory inventories

In an example above, ansible was instructed to use specific private key (overriding the value from ansible.cfg), root user was set as ssh user and playbook variable was set, so that checkout will be made from katello user.

```sh
echo -e "[foreman]\foreman.example.com" >> inventories/local_inventory
ansible-playbook --inventory inventories/local_inventory -l foreman playbooks/foreman.yml
```
Above you can see another example, at this moment, we have two groups in the `inventories/local_inventory` file. Using the flag `-l`, we can set the group that we would like to call, here we can see `foreman`, which means, only the server set on this group will be affected, if you omit it, all hosts will be the standard. Also, the user vagrant will be used once it's defined as default remote user on `ansible.cfg` file.

Other playbooks from playbooks/ directory can be used similarly, though some might need more variables and investigating their parameters is recommended first.

### Credentials
Expand Down