Ansible playbook for installing kubectl on Virtual machine from Ansible-Galaxy Role andrewrothstein.kubectl.
These playbooks are intended to be a reference and starter's guide to building Ansible Playbooks for use with IBM Cloud and Schematics. These playbooks were tested on CentOS 7.x so we recommend that you use CentOS or RHEL to test these modules.
- SSH Key on IBM Cloud
Input variable | Required/ optional | Data type | Description |
---|---|---|---|
Bastion_IP | Required | String | bastion floating IP address |
VSI_IP | Required | String | IBM Cloud VSI IP address |
SSH_KEY | Required | String | IBM Cloud SSH Private key used for VSI installation |
- Open the Schematics action configuration page.
- Review the name for your action, and the resource group and region where you want to create the action. Then, click Create.
- Select the
site.yml
playbook. - Select the Verbosity level to control the depth of information that will be shown when you run the playbook in Schematics.
- Expand the Advanced options.
- Enter all required input variables as key-value pairs. Then, click Save.
- Click Check action to verify your action details. The Jobs page opens automatically. You can view the results of this check by looking at the logs.
- Click Run action to deploy the kubectl. You can monitor the progress of this action by reviewing the logs on the Jobs page.
- Create the Schematics action. Enter all the input variable values that you retrieved earlier. When you run this command and are prompted to enter a GitHub token, enter the return key to skip this prompt.
ibmcloud schematics action create --name kubectl --location us-south --resource-group default --template https://github.com/Cloud-Schematics/ansible-kubectl --playbook-name site.yml
Example output:
Enter github-token>
The given --inputs option region: is not correctly specified. Must be a variable name and value separated by an equals sign, like --inputs key=value.
ID us-south.ACTION.kubectl.1aa11a1a
Name kubectl
Description
Resource Group default
user State live
OK
-
Verify that your Schematics action is created and note the ID that was assigned to your action.
ibmcloud schematics action list
-
Create a job to run a check for your action. Replace
<action_ID>
with the action ID that you retrieved. In your CLI output, note the ID that was assigned to your job.ibmcloud schematics job run --command-object action --command-object-id <action_ID> --command-name ansible_playbook_check
Example output:
ID us-south.JOB.kubectl.fedd2fab Command Object action Command Object ID us-south.ACTION.kubectl.1aa11a1a Command Name ansible_playbook_check Name JOB.kubectl.ansible_playbook_check.2 Resource Group a1a12aaad12b123bbd1d12ab1a123ca1
-
Verify that your job ran successfully by retrieving the logs.
ibmcloud schematics job logs --id <job_ID>
-
Create another job to run the action. Replace
<action_ID>
with your action ID.ibmcloud schematics job run --command-object action --command-object-id <action_ID> --command-name ansible_playbook_run
-
Verify that your job ran successfully by retrieving the logs.
ibmcloud schematics job logs --id <job_ID>
Check the job logs for of TASK: Display Index page content
. The content should give information about installation successful if everything completed successfully.
Log into your VSI Instance by ssh to VSI using bastion, below is the command
ssh -i <ssh_privatekey_path> -o ProxyCommand="ssh -i <ssh_privatekey_path> -W %h:%p root@<bastion_ip>" root@<vsi_ip>
Check whether Kubectl is installed or not.