Skip to content

Commit

Permalink
still need tasks specs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianriobo committed Nov 17, 2023
1 parent 135cbe9 commit 6fc12dc
Show file tree
Hide file tree
Showing 251 changed files with 22,371 additions and 10,473 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION ?= 0.0.6-dev
VERSION ?= 0.6.0
CONTAINER_MANAGER ?= podman
# Image URL to use all building/pushing image targets
IMG ?= quay.io/rhqp/qenvs:v${VERSION}
Expand Down
4 changes: 3 additions & 1 deletion cmd/cmd/aws/hosts/fedora.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const (
cmdFedora = "fedora"
cmdFedoraDesc = "create fedora dedicated host"
cmdFedoraDesc = "manage fedora dedicated host"

fedoraVersion string = "version"
fedoraVersionDesc string = "version for the Fedora Cloud OS"
Expand Down Expand Up @@ -66,6 +66,8 @@ func getFedoraCreate() *cobra.Command {
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
flagSet.StringP(fedoraVersion, "", fedoraVersionDefault, fedoraVersionDesc)
flagSet.Bool(airgap, false, airgapDesc)
flagSet.Bool(spot, false, spotDesc)
c.PersistentFlags().AddFlagSet(flagSet)
return c
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd/aws/hosts/mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

const (
cmdMac = "mac"
cmdMacDesc = "create mac instances"
cmdMacDesc = "manage mac instances"
checkStateCmd = "check-state"
checkStateCmdDesc = "check the state for a dedicated mac machine"

Expand Down
24 changes: 12 additions & 12 deletions cmd/cmd/aws/hosts/rhel.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (

const (
cmdRHEL = "rhel"
cmdRHELDesc = "create rhel dedicated host"
cmdRHELDesc = "manage rhel dedicated host"

rhelVersion string = "version"
rhelVersionDesc string = "version for the RHEL OS"
rhelVersionDefault string = "9.3"
subsUsername string = "subs-username"
subsUsername string = "rh-subscription-username"
subsUsernameDesc string = "username to register the subscription"
subsUserpass string = "subs-userpass"
subsUserpass string = "rh-subscription-password"
subsUserpassDesc string = "password to register the subscription"
profileSNC string = "snc"
profileSNCDesc string = "if this flag is set the RHEL will be setup with SNC profile. Setting up all requirements to run https://github.com/crc-org/snc"
Expand Down Expand Up @@ -75,20 +75,20 @@ func getRHELCreate() *cobra.Command {
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
flagSet.StringP(rhelVersion, "", rhelVersionDefault, rhelVersionDesc)
flagSet.StringP(subsUsername, "", "", amiUsernameDesc)
flagSet.StringP(subsUsername, "", "", subsUsernameDesc)
flagSet.StringP(subsUserpass, "", "", subsUserpassDesc)
flagSet.Bool(airgap, false, airgapDesc)
flagSet.Bool(spot, false, spotDesc)
flagSet.Bool(profileSNC, false, profileSNCDesc)
c.PersistentFlags().AddFlagSet(flagSet)
if err := c.MarkFlagRequired(subsUsername); err != nil {
logging.Error(err)
return nil
}
if err := c.MarkFlagRequired(subsUserpass); err != nil {
logging.Error(err)
return nil
}
// if err := c.MarkFlagRequired(subsUsername); err != nil {
// logging.Error(err)
// return nil
// }
// if err := c.MarkFlagRequired(subsUserpass); err != nil {
// logging.Error(err)
// return nil
// }
return c
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd/aws/hosts/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (

const (
cmdWindows = "windows"
cmdWindowsDesc = "create windows dedicated host"
cmdWindowsDesc = "manage windows dedicated host"

amiName string = "ami-name"
amiNameDesc string = "name for the custom ami to be used within windows machine. Check README on how to build it"
amiNameDefault string = "Windows_Server-2019-English-Full-HyperV-RHQE"
amiNameDefault string = "Windows_Server-2022-English-Full-HyperV-RHQE"
amiUsername string = "ami-username"
amiUsernameDesc string = "name for de default user on the custom AMI"
amiUsernameDefault string = "ec2-user"
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd/azure/azure.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package azure

import (
"github.com/adrianriobo/qenvs/cmd/cmd/azure/windows"
"github.com/adrianriobo/qenvs/cmd/cmd/azure/hosts"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -23,6 +23,6 @@ func GetCmd() *cobra.Command {
},
}

c.AddCommand(windows.GetCmd())
c.AddCommand(hosts.GetWindowsDesktopCmd())
return c
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package windows
package hosts

import (
params "github.com/adrianriobo/qenvs/cmd/cmd/constants"
Expand All @@ -25,7 +25,7 @@ const (
defaultVersion = "11"
paramFeature = "windows-featurepack"
paramFeatureDesc = "windows feature pack"
defaultFeature = "22h2-pro"
defaultFeature = "23h2-pro"
paramUsername = "username"
paramUsernameDesc = "username for general user. SSH accessible + rdp with generated password"
defaultUsername = "rhqp"
Expand All @@ -36,7 +36,7 @@ const (
paramSpotDesc = "if spot is set the spot prices across all regions will be cheked and machine will be started on best spot option (price / eviction)"
)

func GetCmd() *cobra.Command {
func GetWindowsDesktopCmd() *cobra.Command {
c := &cobra.Command{
Use: cmd,
Short: cmdDesc,
Expand Down
59 changes: 59 additions & 0 deletions docs/aws/rhel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Overview

This actions will handle provision RHELServer machines on dedicated hosts. This is a requisite to run nested virtualization on AWS.

As a special case it offers the `profileSNC` option if that flag is set the instance will setup all requirements to run
[single node cluster builder process](https://github.com/crc-org/snc)

## Create

```bash
qenvs aws windows create -h
create

Usage:
qenvs aws windows create [flags]

Flags:
--airgap if this flag is set the host will be created as airgap machine. Access will done through a bastion
--ami-name string name for the custom ami to be used within windows machine. Check README on how to build it (default "Windows_Server-2019-English-Full-HyperV-RHQE")
--ami-owner string alias name for the owner of the custom AMI (default "self")
--ami-username string name for de default user on the custom AMI (default "ec2-user")
--conn-details-output string path to export host connection information (host, username and privateKey)
-h, --help help for create
--spot if this flag is set the host will be created only on the region set by the AWS Env (AWS_DEFAULT_REGION)
--tags stringToString tags to add on each resource (--tags name1=value1,name2=value2) (default [])

Global Flags:
--backed-url string backed for stack state. Can be a local path with format file:///path/subpath or s3 s3://existing-bucket
--project-name string project name to identify the instance of the stack
```
### Outputs
* It will crete an instance and will give as result several files located at path defined by `--conn-details-output`:
* **host**: host for the windows machine (lb if spot)
* **username**: username to connect to the machine
* **id_rsa**: private key to connect to machine
* **bastion_host**: host for the bastion (airgap)
* **bastion_username**: username to connect to the bastion (airgap)
* **bastion_id_rsa**: private key to connect to the bastion (airgap)
* Also it will create a state folder holding the state for the created resources at azure, the path for this folder is defined within `--backed-url`, the content from that folder it is required with the same project name (`--project-name`) in order to detroy the resources.
### Container
When running the container image it is required to pass the authetication information as variables(to setup AWS credentials there is a [helper script](./../../hacks/aws_setup.sh)), following a sample snipped on how to create an instance with default values:
```bash
podman run -d --name qenvs-rhel \
-v ${PWD}:/workspace:z \
-e AWS_ACCESS_KEY_ID=XXX \
-e AWS_SECRET_ACCESS_KEY=XXX \
-e AWS_DEFAULT_REGION=us-east-1 \
quay.io/rhqp/qenvs:0.0.6-dev aws windows create \
--project-name qenvs-windows \
--backed-url file:///workspace \
--conn-details-output /workspace
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.8.1
github.com/pulumi/pulumi-aws/sdk/v5 v5.42.0
github.com/pulumi/pulumi-aws/sdk/v6 v6.2.0
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.17.0
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.17.0
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.17.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/pulumi/esc v0.5.6 h1:4WV3X7OEVcChIwbSG+JxhZDdmq/q7lFPaSjHRYlPwmI=
github.com/pulumi/esc v0.5.6/go.mod h1:wpwNfVS5fV7Kd51j4dJ6FWYlKfxdqyppgp0gtkzqH04=
github.com/pulumi/pulumi-aws/sdk/v5 v5.42.0 h1:QdJvPoUklXdNL8faCOuCrv7qmMNp68jiewbGH8ZboUU=
github.com/pulumi/pulumi-aws/sdk/v5 v5.42.0/go.mod h1:qFeKTFSNIlMHotu9ntOWFjJBHtCiUhJeaiUB/0nVwXk=
github.com/pulumi/pulumi-aws/sdk/v6 v6.2.0 h1:Q3H+xHE1Yjeqymcs0nFhdi7BA45iziAKLQJo6/i4RTA=
github.com/pulumi/pulumi-aws/sdk/v6 v6.2.0/go.mod h1:UeOesX8l9ntIiiKXdQue8/rQDAvSf7Spd5qf15qngcY=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.17.0 h1:kYxrIm+sHForUKxLY7hq+HZplK8sRRt9MhboFUopg+Q=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.17.0/go.mod h1:twIKkk+bFufgRpeUNp5sq7G/T4mrxzNL6Mxtk5jRL9w=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.17.0 h1:IHizzMI1G9XNrSBnZBmXOgMhwZtsEkmzhqE5rPMHX5U=
Expand Down
2 changes: 1 addition & 1 deletion oci/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ENV INTERNAL_OUTPUT=/tmp/qenvs \

VOLUME [ "${INTERNAL_OUTPUT}" ]

ENV AWS_CLI_VERSION 2.13.17
ENV AWS_CLI_VERSION 2.13.36
ENV AWS_CLI_URL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip

ENV AZ_CLI_VERSION 2.54.0
Expand Down
11 changes: 8 additions & 3 deletions pkg/provider/aws/action/fedora/fedora.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/adrianriobo/qenvs/pkg/provider/util/output"
"github.com/adrianriobo/qenvs/pkg/util"
resourcesUtil "github.com/adrianriobo/qenvs/pkg/util/resources"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
Expand Down Expand Up @@ -47,9 +47,10 @@ func Create(r *Request) error {
if r.Spot {
sr := spot.SpotOptionRequest{
Prefix: r.Prefix,
ProductDescription: "Linux",
ProductDescription: "Linux/UNIX",
InstaceTypes: requiredInstanceTypes,
AMIName: fmt.Sprintf(amiRegex, r.Version),
AMIArch: "x86_64",
}
so, err := sr.Create()
if err != nil {
Expand Down Expand Up @@ -130,7 +131,11 @@ func (r *Request) createAirgapMachine() error {
// * checks
func (r *Request) deploy(ctx *pulumi.Context) error {
// Get AMI
ami, err := amiSVC.GetAMIByName(ctx, fmt.Sprintf(amiRegex, r.Version), amiOwner, nil)
ami, err := amiSVC.GetAMIByName(ctx,
fmt.Sprintf(amiRegex, r.Version),
amiOwner,
map[string]string{
"architecture": "x86_64"})
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/aws/action/mac/mac-dh.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/adrianriobo/qenvs/pkg/provider/util/output"
"github.com/adrianriobo/qenvs/pkg/util/logging"
resourcesUtil "github.com/adrianriobo/qenvs/pkg/util/resources"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/aws/action/mac/mac-machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
resourcesUtil "github.com/adrianriobo/qenvs/pkg/util/resources"
"github.com/aws/aws-sdk-go/aws/session"
awsEC2 "github.com/aws/aws-sdk-go/service/ec2"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi-command/sdk/go/command/remote"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi-tls/sdk/v4/go/tls"
Expand Down
11 changes: 8 additions & 3 deletions pkg/provider/aws/action/rhel/rhel.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/adrianriobo/qenvs/pkg/util"
"github.com/adrianriobo/qenvs/pkg/util/file"
resourcesUtil "github.com/adrianriobo/qenvs/pkg/util/resources"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
Expand Down Expand Up @@ -70,6 +70,7 @@ func Create(r *Request) error {
ProductDescription: "Red Hat Enterprise Linux",
InstaceTypes: requiredInstanceTypes,
AMIName: fmt.Sprintf(amiRegex, r.Version),
AMIArch: "x86_64",
}
so, err := sr.Create()
if err != nil {
Expand Down Expand Up @@ -149,8 +150,12 @@ func (r *Request) createAirgapMachine() error {
// * compute
// * checks
func (r *Request) deploy(ctx *pulumi.Context) error {

ami, err := amiSVC.GetAMIByName(ctx, fmt.Sprintf(amiRegex, r.Version), "", nil)
// Get AMI
ami, err := amiSVC.GetAMIByName(ctx,
fmt.Sprintf(amiRegex, r.Version),
"",
map[string]string{
"architecture": "x86_64"})
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/aws/action/windows/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var (
amiNameDefault = "Windows_Server-2019-English-Full-HyperV-RHQE"
amiOwnerDefault = "self"
amiUserDefault = "ec2-user"
amiArchDefault = "x86_64"

// Custom non english ami
amiLangNonEng = "non-eng"
Expand Down
6 changes: 4 additions & 2 deletions pkg/provider/aws/action/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/adrianriobo/qenvs/pkg/util"
"github.com/adrianriobo/qenvs/pkg/util/file"
resourcesUtil "github.com/adrianriobo/qenvs/pkg/util/resources"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
Expand All @@ -39,6 +39,7 @@ type Request struct {
AMIUser string
AMIOwner string
AMILang string
AMIArch string
Spot bool
Airgap bool
// internal management
Expand Down Expand Up @@ -69,6 +70,7 @@ func Create(r *Request) error {
r.AMIName = amiNameDefault
r.AMIUser = amiUserDefault
r.AMIOwner = amiOwnerDefault
r.AMIArch = amiArchDefault
}
if len(r.AMILang) > 0 && r.AMILang == amiLangNonEng {
r.AMIName = amiNonEngNameDefault
Expand Down Expand Up @@ -97,7 +99,7 @@ func Create(r *Request) error {
}
r.az = *az
}
isAMIOffered, _, err := amiSVC.IsAMIOffered(r.AMIName, r.region)
isAMIOffered, _, err := amiSVC.IsAMIOffered(r.AMIName, r.AMIArch, r.region)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/aws/modules/ami/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/adrianriobo/qenvs/pkg/provider/aws"
"github.com/adrianriobo/qenvs/pkg/provider/aws/data"
"github.com/adrianriobo/qenvs/pkg/util/logging"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

Expand Down
5 changes: 3 additions & 2 deletions pkg/provider/aws/modules/ami/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import (
qenvsContext "github.com/adrianriobo/qenvs/pkg/manager/context"
"github.com/adrianriobo/qenvs/pkg/provider/aws"
amiSVC "github.com/adrianriobo/qenvs/pkg/provider/aws/services/ec2/ami"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

type CopyAMIRequest struct {
Prefix string
ID string
AMISourceName string
AMISourceArch string
// AMITargetName string
// If AMITargetRegion is nil
// it will be copied to all regions
Expand Down Expand Up @@ -90,7 +91,7 @@ func (r CopyAMIRequest) createStack() error {
// and it will export the data from the best spot option to the stack state
func (r CopyAMIRequest) deployer(ctx *pulumi.Context) error {
// find were the ami is
amiInfo, err := amiSVC.FindAMIByName(r.AMISourceName)
amiInfo, err := amiSVC.FindAMI(r.AMISourceName, r.AMISourceArch)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/aws/modules/bastion/bastion.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/adrianriobo/qenvs/pkg/provider/util/output"
"github.com/adrianriobo/qenvs/pkg/util"
resourcesUtil "github.com/adrianriobo/qenvs/pkg/util/resources"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi-tls/sdk/v4/go/tls"
"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
Expand Down
Loading

0 comments on commit 6fc12dc

Please sign in to comment.