Skip to content

Commit

Permalink
Initial check in.
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-zhang committed Nov 15, 2023
1 parent e2cc610 commit 44e862d
Show file tree
Hide file tree
Showing 247 changed files with 16,452 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# terraform.lock.hcl
.terraform.lock.hcl

# temp or backup files
vars
*.bak
123 changes: 123 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement. Contact with repository owners.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Contributing

This project is [Apache 2.0 Licenced](LICENCE.txt) and welcomes external contributions. When contributing to this repository, please first discuss the change you wish to make via an [issue](https://github.com/ocp-power-automation/ocp4-ai-power/issues).

Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.

# Issues

- If you find any issue with the code or documentation please submit an [issue](https://github.com/ocp-power-automation/ocp4-ai-power/issues).
- It is best to check out existing issues first to see if a similar one is open or has already been discussed.


# Pull Request Process

- To contribute code or documentation, please submit a [pull request](https://github.com/ocp-power-automation/ocp4-ai-power/pulls).
- Always take the latest update from upstream/main before creating a pull request.
- Ensure your changes work fine and have no syntax problems. Also, verify that it does not break the existing code flow.
- Update the README.md or relevant documents with details of changes to the code. This includes variables change, added or updated feature, change in steps, dependencies change, etc.
- Make use of proper commit message. Mention the issue# which you are planning to address eg: Fixes #38.
- After creating the pull request ensure you implement all the review comments given if any. Pull request will be merged only when it has at least two approvals from the list of reviewers.
- Please read [Developer Certificate of Origin](DCO1.1.txt) and sign-off your commit using command `git commit -s`.


# Spec Formatting Conventions
Documents in this repository will adhere to the following rules:

- Lines are wrapped at 80 columns (when possible)
- Use spaces to indent your code. Do not use tab character, instead can use 2/4 spaces.

26 changes: 26 additions & 0 deletions DCO1.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

File renamed without changes.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Introduction
The `ocp4-ai-power` [project](https://github.com/ocp-power-automation/ocp4-ai-power) provides Terraform based automation code to help the deployment of OpenShift Container Platform (OCP) 4.x on PowerVM systems with Agent-based installer, assisted installer and SNO. It can be used for IBM PowerVS, PowerVC and HMC. The difference between this playbook and other UPI playbooks is it uses net boot or bootp method for OCP installation.

!!! Note
For bugs/enhancement requests etc. please open a GitHub [issue](https://github.com/ocp-power-automation/ocp4-ai-power/issues)

# Directory structure
There are 5 subdirectories for `ocp4-ai-power`:
- ansible-bastion -- ansible play book to setup bastion, create OCP configuration and perform OCP installation and customization
- data -- default place to store private, public key and pull secret
- tf-common -- Common modules for terraform
- tf-powervc -- Terraform modules for PowerVC, it is the working directory for PowerVC
- tf-powervs -- Terraform modules for PowerVS, it is the working directory for PowerVS (WIP)

# For PowerVC

Follow the [guide](tf-powervc/README.md) for OCP installation on PowerVM LPARs managed via PowerVC

# For PowerVS (WIP)

Follow the [guide](tf-powervs/README.md) for OCP installation on PowerVM LPARs managed via PowerVS (this part is not work yet)

95 changes: 95 additions & 0 deletions ansible-bastion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Install Openshift cluster for PowerVM

This playbook can be used to install Openshift cluster to PowerVM, it supports 4 types of installation:
1. Agent-based Installation
2. Assisted-service based installation
3. Single node cluster installation without bootstrap
4. Normal OCP cluster installation

## Prepare the bastion

The bastion's `SELINUX` has to be set to `permissive` mode, otherwise ansible playbook will fail, to do it open file `/etc/selinux/config` and set `SELINUX=permissive`.

Create the ssh key which will be used for OCP installation:
```shell
ssh-keygen -t rsa -b 2048 -N '' -C 'BASTION-SSHKEY' -f ~/.ssh/id_rsa"
```
Download the pull-secret from [try.openshift.com](https://cloud.redhat.com/openshift/install/pre-release) and save it as `~/.openshift/pull-secret` on the bastion.
Setup the password-less access to HMC:
```shell
# <hscroot> is the userid, <hmc_ip> is the HMC IP address
ssh <hscroot>@<hmc_ip>
# <~/.ssh/id_rsa.pub> is the content of ~/.ssh/id_rsa.pub
mkauthkeys -a "<~/.ssh/id_rsa.pub>"
```
The `bastion` need to install required packages to be able to run this playbook, it requires to run as root. All OCP nodes need to have the static IP assigned with internet access.
Install base with this script, it can be run on CentOS or Redhat Linux:
```shell
cat > setup-bastion.sh << EOF
DISTRO=$(lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 || uname -om || echo "")
OS_VERSION=$(lsb_release -rs 2>/dev/null || cat /etc/*release 2>/dev/null | grep "VERSION_ID" | awk -F "=" '{print $2}' | sed 's/"*//g' || echo "")
if [[ "$DISTRO" != *CentOS* ]]; then # for Redhat
if [[ $(cat /etc/redhat-release | sed 's/[^0-9.]*//g') > 8.5 ]]; then
sudo subscription-manager repos --enable codeready-builder-for-rhel-9-ppc64le-rpms
sudo yum install -y ansible-core
else
sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-ppc64le-rpms
sudo yum install -y ansible
fi
else # for centos
if [[ $OS_VERSION != "8"* ]]; then
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
sudo yum install -y ansible-core
else
sudo yum install -y epel-release epel-next-release
sudo yum config-manager --set-enabled powertools
sudo yum install -y ansible
fi
fi
# install additional modules for ansible
sudo ansible-galaxy collection install community.crypto --upgrade
sudo ansible-galaxy collection install community.general --upgrade
sudo ansible-galaxy collection install ansible.posix --upgrade
sudo ansible-galaxy collection install kubernetes.core --upgrade
# install all required packages
sudo yum install -y wget jq git net-tools vim tar unzip python3 python3-pip python3-jmespath coreos-installer grub2-tools-extra bind-utils
# install files for PXE
sudo grub2-mknetdir --net-directory=/var/lib/tftpboot
EOF
chmod +x setup-bastion.sh
./setup-bastion.sh
```
Clone this playbook from `github.com` to bastion:
```shell
git clone https://github.com/cs-zhang/ocp4-ai-powervm.git
```
## Create the vars.yaml
Go `ocp4-ai-powervm` and create new vars.file from the `example-vars.yaml`
```shell
cd ocp4-ai-powervm
cp example-vars.yaml vars.yaml
```
Modify the `vars.yaml` based on the [doc](docs/vars-doc.md).
>Note: Before modify the `vars.yaml`, you have to create all required VMs(LPARs), then you will have LPAR the network info to update the `vars.yaml`.
## Deploy the Cluster
Now we have every thing set, and we can run the playbook:
```shell
cd ocp4-ai-powervm
ansible-playbook -e @vars.yaml playbooks/main.yaml
```
7 changes: 7 additions & 0 deletions ansible-bastion/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[defaults]
inventory = inventory
command_warnings = False
filter_plugins = filter_plugins
host_key_checking = False
deprecation_warnings=False
retry_files = false
Loading

0 comments on commit 44e862d

Please sign in to comment.