...
cd <to the correct directory where terraformfilelive.tf >
#terraform init ( only the first time, will download provider module )
terraform plan
terraform apply ( type "yes" to confirm )
terraform destroy ( at the end and type "yes" to confirm)
...
ssh-keygen # will create a pair of private key ( id_rsa) and a public key ( id_rsa.pub )
chmod 0600 .ssh/id_rsa # safety reason!!!
#test: ssh localhost
#ssh-copy-id localhost ( or IP@) # copy the public key to ".ssh/authorized_keys"
Code Block |
---|
title | instance.yaml for BMSinstall contrail on AWS |
---|
collapse | true |
---|
|
[centos@centos7_new ~]$ more /tmp/contrail-ansible-deployer/config/instances.yaml
provider_config:
bms:
instances:
bms1:
provider: bms
ip: 192.168.1.100
global_configuration:
CONTAINER_REGISTRY: opencontrailnightly
contrail_configuration:
CONTRAIL_VERSION: latest
|
Code Block |
---|
title | install contrail on AWS |
---|
collapse | true |
---|
|
In the case the installation is done "locally": log into the VM in AWS, and then do the installation from here: the VM AWS
----------------------------------------------------------------- In the case the installation is done "locally": log into the VM in AWS, and then do the installation from here: the VM AWS
--------------------------------------------------------------------------------------------------------------------------
1- On the Local PC: Terraform >>>> create the VM on AWS ( with the key )
2- # On the Local PC: Ansible push the configuration steps to the VM on AWS >>>> Manually log into the AWS' VM and run the commands
1- Log as "centos" user ( same as the VM on AWS, just make it easier )
2- upload the key on the local PC ( same key as on the VM AWS, make it easier to log into it )
3- # ssh-keygen ( .ssh/id_rsa is the default, passphrase cont... ) # not needed becuase I will use the same key as AWS
ssh-agent bash
ssh-add ~/.ssh/TerraformKeyPair.pem
# ssh-add -l or ssh-add -L #just to check
more .ssh/authorized_keys >>> can see the terraformapukey ( to log into the VM remotely : home to AWS DC)
vi .ssh/authorized_keys # add the key from "ssh-add -L "
ssh localhost # just to check that the key has been copy and works
exit
#ssh-copy-id <10.0.1.104>
#Centos
#sudo yum install -y ansible-2.4.2.0
#sudo yum install git -y
#Ubuntu
sudo pip install ansible==2.4.2.0
sudo apt-get install git -y
git clone http://github.com/Juniper/contrail-ansible-deployer
cd contrail-ansible-deployer
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/provision_instances.yml
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/configure_instances.yml
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/install_contrail.yml
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/install_k8s.yml
---------------------------------------------------------
1- On the Local PC: Terraform >>>> create the VM on AWS ( with the key )
2- # On the Local PC: Ansible push the configuration steps to the VM on AWS >>>> Manually log into the AWS' VM and run the commands
1- Log as "centos" user ( same as the VM on AWS, just make it easier )
2- upload the key on the local PC ( same key as on the VM AWS, make it easier to log into it )
3- # ssh-keygen ( .ssh/id_rsa is the default, passphrase cont... ) # not needed becuase I will use the same key as AWS
ssh-agent bash
ssh-add ~/.ssh/TerraformKeyPair.pem
# ssh-add -l or ssh-add -L #just to check
more .ssh/authorized_keys >>> can see the terraformapukey ( to log into the VM remotely : home to AWS DC)
vi .ssh/authorized_keys # add the key from "ssh-add -L "
ssh localhost # just to check that the key has been copy and works
exit
#ssh-copy-id <10.0.1.104>
#Centos
#sudo---------------------------------------
#ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"10.0.1.104","provider":"bms"}}}' playbooks/configure_instances.yml
#ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"10.0.1.104","provider":"bms"}}}' playbooks/install_contrail.yml
#ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"192.168.1.100","provider":"bms"}}}' playbooks/install_k8s.yml
ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"localhost","provider":"bms"}}}' playbooks/configure_instances.yml
ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"localhost","provider":"bms"}}}' playbooks/install_contrail.yml
ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"localhost","provider":"bms"}}}' playbooks/install_k8s.yml
|
Code Block |
---|
title | instance.yaml for BMS |
---|
collapse | true |
---|
|
[centos@centos7_new ~]$ more /tmp/contrail-ansible-deployer/config/instances.yaml
Will be move to >>>> more /etc/ansible/roles/contrail50/files/instances.yaml
provider_config:
bms:
instances:
bms1:
provider: bms
ip: 192.168.1.100
global_configuration:
CONTAINER_REGISTRY: opencontrailnightly
contrail_configuration:
CONTRAIL_VERSION: latest |
Code Block |
---|
title | ansible hosts file |
---|
collapse | true |
---|
|
[centos@centos7_new ansible]$ more /etc/ansible/hosts
[centos7_new]
localhost ansible_connection=local
[web]
[aws]
35.162.40.232
|
Code Block |
---|
title | ansible main.yml playbook |
---|
collapse | true |
---|
|
[centos@centos7_new ~]$ more /etc/ansible/roles/contrail50/tasks/main.yml
---
# tasks file for contrail50
- hosts: aws
vars:
orch: -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"10.0.1.220","provider":"bms"}}}'
tasks:
- name: Install Ansible
shell: 'sudo yum install -y ansible-2.4.2.0'
#sudo
yum install git -y name: Install #Ubuntu sudoGIT pipto install ansible==2.4.2.0
sudo apt-get install git -y
git clone http://github.com/Juniper/contrail-ansible-deployer
cd contrail-ansible-deployer
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/provision_instances.yml
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/configure_instances.yml
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/install_contrail.yml
ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/install_k8s.yml
-------------------------------------------------------------------------------------------
#ansibledownload Contrail Ansible Installation Playbook
shell: 'sudo yum install git -y'
- name: Clone using GIT the Contrail Ansible Installation Playbook
git:
repo: 'http://github.com/Juniper/contrail-ansible-deployer'
dest: /home/centos/contrail-ansible-deployer
- name: copy a file from local to AWS' VM
copy:
src=/etc/ansible/roles/contrail50/files/instances.yaml
dest=/home/centos/contrail-ansible-deployer/config/instances.yaml
- name: Run the Contrail Ansible Installation Playbook configure_instances.yml
shell: ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"10.0.1.104","provider":"bms"}}}' playbooks/configure_instances.yml
#ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"10.0.1.104","provider":"bms"}}}' playbooks/install_contrail.yml
#ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"192.168.1.100","provider":"bms"}}}' playbooks/install_k8s.yml
ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"localhost","provider":"bms"}}}' playbooks/configure_instances.ymlyml
args:
chdir: /home/centos/contrail-ansible-deployer/
- name: Run the Contrail Ansible Installation Playbook install_contrail.yml
shell: ansible-playbook -i inventory/ playbooks/install_contrail.yml
args:
chdir: /home/centos/contrail-ansible-deployer/
- name: Run the Contrail Ansible Installation Playbook for K8S playbooks/install_k8s.yml
shell: ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"localhost","provider":"bms"}}}' playbooks/install_contrailk8s.yml
ansible-playbook -i inventory/ -e orchestrator=kubernetes -e '{"instances":{"bms1":{"ip":"localhost","provider":"bms"}}}' playbooks/install_k8s.yml
args:
chdir: /home/centos/contrail-ansible-deployer/
|
Issue:
AnsibleUndefinedVariable: 'cassandra_seeds' is undefined"}