Skip to content

Latest commit

 

History

History
291 lines (233 loc) · 11 KB

First_OSP_Env_walkthrough.adoc

File metadata and controls

291 lines (233 loc) · 11 KB

Config on OpenStack

In this document we will explain how one could setup their laptop for AgnosticD deployment with OpenStack.

If you are a Red Hatter, you can use labs.opentlc.com to request access to our OpenStack cluster. . Log in to https://labs.opentlc.com using your opentlc user. . Go to ServicesCatalogsNovello testingDEV OSP Sandbox. . Click OrderSubmit

Note
You will receive three emails indicating the status of the environment and instructions for accessing the environment. In the third email you receive all information you need to login to the client machine that would have the rest of required information.
Note
You can use the VM as your ansible host or copy the files over to your laptop and work locally.

Configure your environment for running OpenStack Ansible

Note
on Fedora dnf install python3-openstacksdk python3-openstackclient python-openstackclient-doc python-openstackclient-lang python3-heatclient python-heatclient-doc python3-dns will do the job (you may choose to skip doc and lang packages).
  1. Please make sure the file /etc/ansible/hosts doesn’t exist or is empty, otherwise this default inventory file will cause problems later.

  2. Install virtualenv and pip3 (On your laptop or on the clientVM):

    # on Linux
    $ sudo yum install python3-pip python-virtualenv -y
    # on Mac
    $ brew install python pyenv-virtualenv
  3. Create virtualenv environment and download python requirements:

    1. Create virtualenv and activate

      $ virtualenv openstack-ansible-2.9
      
      ##In Mac
      $ pyenv virtualenv openstack-ansible-2.9
      
      
      ## In Mac, if you find the error " the error: error: pyenv: pip: command not found]", it could because you need pip3, in that case please do:
      $ alias pip=pip3
      $ pip install --upgrade pip
      
      $ source openstack-ansible-2.9/bin/activate
      
      ## In Mac
      $ source /Users/[USER]/.pyenv/versions/openstack-ansible-2.9/bin/activate
      
      ## ^replace [USER] with your username or the proper path
    2. Install the python modules inside that virtualenv

      • On Mac

        $ pip3 install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/ansible/configs/ocp4-disconnected-osp-lab/files/macos_requirements.txt
      • On Linux with Python 2

        (openstack-ansible-2.9) $ pip install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/tools/virtualenvs/openstack-ansible-2.9-python2.txt
      • On Linux with python 3:

        (openstack-ansible-2.9) $ pip install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/tools/virtualenvs/openstack-ansible-2.9-python3.txt
      • Multi-platform, latest modules (should work for all with both python2 and python3)

        (openstack-ansible-2.9) $ pip install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/tools/virtualenvs/openstack-ansible-latest.txt
# Install python modules needed by ansible
sudo pip install openstacksdk

# Install openstack CLIs
sudo pip install python-openstackclient python-heatclient

Getting your OpenStack Credentials

  1. Create the ~/.config/openstack/clouds.yaml file on your laptop using the information provided in the final email.

    $ mkdir -p ~/.config/openstack
    $ vim ~/.config/openstack/clouds.yaml
  2. Review your ~/.config/openstack/clouds.yaml:

    cat ~/.config/openstack/clouds.yaml
    clouds:
      35eb-project:
        auth:
          auth_url: "http://169.47.17.15:5000/v3"
          username: "35eb-user"
          project_name: "35eb-project"
          project_id: "1a79cf800ff94754bb495e2c1fd9d433"
          user_domain_name: "Default"
          password: "YOUR_TEMP_PASSWORD"
        region_name: "regionOne"
        interface: "public"
        identity_api_version: 3
  3. Check that your credentials are working. In order to do so, first log into your bastion, using the credentials provided to you via email:

    sassenach:~ Cibeles$ ssh [email protected]
    [email protected]'s password: YOUR_EMAIL_PROVIDED_PASSWORD
    $ openstack --os-cloud=GUID-project server list
    +--------------------------------------+-----------+--------+------------------------------------------------+-------+---------+
    | ID                                   | Name      | Status | Networks                                       | Image | Flavor  |
    +--------------------------------------+-----------+--------+------------------------------------------------+-------+---------+
    | 653fb842-6ce8-4eb0-a51a-dc0f3d5fb103 | bastion   | ACTIVE | 35eb-ocp-network=192.168.47.33, 169.47.183.214 |       | 2c2g30d |
    +--------------------------------------+-----------+--------+------------------------------------------------+-------+---------+
  4. Try to login to OpenStack UI: http://horizon.red.osp.opentlc.com/dashboard/auth/login/. You must use the credentials from .config/openstack/clouds.yaml to login to the UI.

Setting up AgnosticD and your development environment

  1. Clone the AgnosticD repository:

    git clone https://github.com/redhat-cop/agnosticd
  2. Create your secret.yml file oustide the repository, and edit it using the correct credentials based on your clouds.yml file:

    cat << EOF >> ~/secret.yml
    # Authenication for OpenStack in order to create the things
    # RED
    osp_auth_username: CHANGEME
    osp_auth_password: CHANGEME
    osp_project_name: CHANGEME
    osp_project_id: CHANGEME
    
    
    osp_auth_url: http://169.47.188.15:5000/v3
    osp_auth_project_domain: default
    osp_auth_user_domain: default
    
    # DNS
    
    osp_cluster_dns_server: ddns01.opentlc.com
    osp_cluster_dns_zone: students.osp.opentlc.com
    ddns_key_name: PROVIDED_BY_ADMIN          # default value is set to "hmac-dm5"
    ddns_key_secret: PROVIDED_BY_ADMIN
    
    # Repo
    
    own_repo_path: PROVIDED_BY_ADMIN
    
    # Do not create PROJECT, we already have one and want to use it
    
    osp_project_create: false
    
    EOF
Note
You can find a secret.yml file provided to you on the home directory of your user at your bastion machine, use this to populate the file as previously stated.

+

[YOUR_USER@bastion ~]$ ls
agnosticd  secrets.yaml
Note
It is required that OpenStack SDK is installed on your working machine. For further information, please refer to its web page
  1. First checkpoint, make sure this secret file is correct by running the test-empty-config.

    cd agnosticd/ansible
    
    ansible-playbook main.yml \
      -e @configs/test-empty-config/sample_vars_osp.yml \
      -e @~/secret.yml
  2. Copy the sample_vars.yml file and call it my_vars.yml

    cp configs/just-a-bunch-of-nodes/sample_vars_osp.yml \
      configs/just-a-bunch-of-nodes/my_vars.yml
  3. Edit the my_vars.yml and change the guid value to something short and unique.

    Warning
    Do not pick the same GUID as the one you got for access to the OSP cluster.
  4. Second checkpoint, Run the ansible-playbook command to deploy just-a-bunch-of-nodes

    ansible-playbook main.yml \
      -e @configs/just-a-bunch-of-nodes/my_vars.yml \
      -e @~/secret.yml
    Note
    If you are having python2 Vs. Python3 issues, Add /usr/bin/python3.6 before the ansible-playbook command. For example: /usr/bin/python3.6 ansible-playbook ansible/main.yml -e @configs/just-a-bunch-of-nodes/my_vars.yml -e@~/secret.yml
  5. Check that the VM was installed and ssh into the box using the created key. In order to do so, first log into your bastion, using the credentials provided to you via email:

    sassenach:~ Cibeles$ ssh [email protected]
    [email protected]'s password: YOUR_EMAIL_PROVIDED_PASSWORD
    [YOUR_USER@bastion ~]$ openstack --os-cloud=${GUID}-project server list
    
    +--------------------------------------+---------+--------+---------------------------------------------------------+-------+---------+
    | ID                                   | Name    | Status | Networks                                                | Image | Flavor  |
    +--------------------------------------+---------+--------+---------------------------------------------------------+-------+---------+
    | 2715f0d9-51e1-4619-a97e-c841914dddf6 | node    | ACTIVE | testamaya-default-network=192.168.47.26                 |       | 2c2g30d |
    | 6931bf5a-ec1e-4ac7-8477-9e96f9e14de3 | bastion | ACTIVE | testamaya-default-network=192.168.47.17, 169.47.188.156 |       | 2c2g30d |
    | 947d6397-c152-4a38-9825-02f9fa50c03e | bastion | ACTIVE | 98e1-testnet-network=192.168.0.35, 169.47.191.80        |       | 2c2g30d |
    +--------------------------------------+---------+--------+---------------------------------------------------------+-------+---------+

You can see there are some machines there and their IP addresses. Now you can log into your bastion machine from the outside world (your laptop) or from the bastion machine you were given credentials for in the email.

Let’s log in from the outside world (your laptop) using your ${GUID}_infra_ssh_key.pem key file. Please note that the key file should be created in the machine you launched the playbook from.

+

sassenach:~ Cibeles$ ll /tmp/output_dir/
 8 -rw-r--r--   1 Cibeles  staff   235B May 26 17:41 basic_heat_template.yml
 8 -rw-r--r--   1 Cibeles  staff   369B May 28 16:38 hosts-just-a-bunch-of-nodes-testamaya
16 -rw-r--r--   1 Cibeles  staff   6.8K May 26 17:42 just-a-bunch-of-nodes.testamaya.osp_cloud_master_template.yaml
 8 -rw-r--r--   1 Cibeles  staff   1.1K May 28 16:32 just-a-bunch-of-nodes_testamaya_ssh_conf
 8 -rw-r--r--   1 Cibeles  wheel   175B May 28 16:33 just-a-bunch-of-nodes_testamaya_ssh_known_hosts
 8 -rwxr--r--   1 Cibeles  staff   168B May 28 16:37 ssh-config-just-a-bunch-of-nodes-testamaya*
 8 -rw-------   1 Cibeles  staff   1.6K May 25 13:16 testamaya_infra_ssh_key.pem
 8 -r--------   1 Cibeles  wheel   1.8K May 28 16:19 testamayakey
 8 -rw-r--r--   1 Cibeles  wheel   399B May 28 16:19 testamayakey.pub

sassenach:~ Cibeles$ ssh -i /tmp/output_dir/testamaya_infra_ssh_key.pem [email protected]
Last login: Thu May 28 10:49:27 2020 from 90.77.177.210
[cloud-user@bastion 0 ~]$
  1. You can now adapt my_vars.yml to your needs. Create different kind of instances, more security groups, etc.

Clean up

  1. Destroy the deployment:

    ansible-playbook destroy.yml \
      -e @configs/just-a-bunch-of-nodes/my_vars.yml \
      -e @~/secret.yml

What’s next ?