From 9c38343e4847bbae791088330d31c6a4c80bd7fd Mon Sep 17 00:00:00 2001 From: Waldirio M Pinheiro Date: Tue, 6 Feb 2024 01:50:48 -0800 Subject: [PATCH 1/5] new changes, when working from MAC OS --- README.md | 6 ++++++ playbooks/foreman.yml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a57b7879e..bf55d63c6 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,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 -e group_name=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 extra vars, 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. 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 diff --git a/playbooks/foreman.yml b/playbooks/foreman.yml index 93e566daa..bcb4ba8bb 100644 --- a/playbooks/foreman.yml +++ b/playbooks/foreman.yml @@ -1,4 +1,4 @@ -- hosts: all +- hosts: " {{ group_name | default('all') }}" become: true roles: - role: foreman From 9ca77bc578aafa21d0bc5e0777f65f7808cca965 Mon Sep 17 00:00:00 2001 From: Waldirio M Pinheiro Date: Tue, 6 Feb 2024 02:01:33 -0800 Subject: [PATCH 2/5] adding some info on README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf55d63c6..cd8ac7385 100644 --- a/README.md +++ b/README.md @@ -131,9 +131,26 @@ 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 echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant ``` +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) +```sh +git clone https://github.com/theforeman/forklift.git +cd forklift +/usr/local/bin/python3-intel64 -m venv ~/.venv/forklift +source ~/.venv/forklift/bin/activate +pip install --upgrade pip +pip install ansible +ansible-galaxy collection install -r requirements.yml +``` + +Now, you can share the ssh key with the server +```sh +ssh-copy-id vagrant@test.example.com +``` + in forklift checkout ```sh echo -e "[devel]\ntest.example.com" > inventories/local_inventory @@ -146,7 +163,7 @@ In an example above, ansible was instructed to use specific private key (overrid echo -e "[foreman]\foreman.example.com" >> inventories/local_inventory ansible-playbook --inventory inventories/local_inventory -e group_name=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 extra vars, 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. Also, the user vagrant will be used once it's defined as default remote user on `ansible.cfg` file. +Above you can see another example, at this moment, we have two groups in the `inventories/local_inventory` file. Using the extra vars, 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. From 34f5033a438244a311ffe6cdf9c4c699abeb6292 Mon Sep 17 00:00:00 2001 From: Waldirio M Pinheiro Date: Tue, 6 Feb 2024 09:44:53 -0800 Subject: [PATCH 3/5] some updates about virtualenv --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd8ac7385..efde7d506 100644 --- a/README.md +++ b/README.md @@ -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) @@ -135,14 +136,22 @@ echo vagrant:redhat | chpasswd 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) ```sh -git clone https://github.com/theforeman/forklift.git -cd forklift /usr/local/bin/python3-intel64 -m venv ~/.venv/forklift source ~/.venv/forklift/bin/activate pip install --upgrade pip pip install ansible +``` +Note. Above, you can see `python3-intel64`. This is very specific for MacOS M1 or M2 with arm processors, just to keep the compatibility with x86. If you have a regular x86, feel free to use `python3` and it should be enough. + + +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 ``` From 33c5b0c69403f24481ec80e1ba2146d2b6003bce Mon Sep 17 00:00:00 2001 From: Waldirio M Pinheiro Date: Tue, 6 Feb 2024 09:47:16 -0800 Subject: [PATCH 4/5] removing the space between characters. --- playbooks/foreman.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/foreman.yml b/playbooks/foreman.yml index bcb4ba8bb..d5c69d390 100644 --- a/playbooks/foreman.yml +++ b/playbooks/foreman.yml @@ -1,4 +1,4 @@ -- hosts: " {{ group_name | default('all') }}" +- hosts: "{{ group_name | default('all') }}" become: true roles: - role: foreman From 1c90987799fbf792fae71b7579598f3db39a5a25 Mon Sep 17 00:00:00 2001 From: Waldirio M Pinheiro Date: Tue, 6 Feb 2024 16:25:30 -0800 Subject: [PATCH 5/5] updating the infos --- README.md | 8 ++++---- playbooks/foreman.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index efde7d506..fa7103870 100644 --- a/README.md +++ b/README.md @@ -140,12 +140,12 @@ echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant 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) ```sh -/usr/local/bin/python3-intel64 -m venv ~/.venv/forklift +/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-intel64`. This is very specific for MacOS M1 or M2 with arm processors, just to keep the compatibility with x86. If you have a regular x86, feel free to use `python3` and it should be enough. +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. Then you can clone forklift and move on @@ -170,9 +170,9 @@ In an example above, ansible was instructed to use specific private key (overrid ```sh echo -e "[foreman]\foreman.example.com" >> inventories/local_inventory -ansible-playbook --inventory inventories/local_inventory -e group_name=foreman playbooks/foreman.yml +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 extra vars, 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. +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. diff --git a/playbooks/foreman.yml b/playbooks/foreman.yml index d5c69d390..93e566daa 100644 --- a/playbooks/foreman.yml +++ b/playbooks/foreman.yml @@ -1,4 +1,4 @@ -- hosts: "{{ group_name | default('all') }}" +- hosts: all become: true roles: - role: foreman