Ansible Playbook to automatically install flink-instances on OpenStack
-
Install:
- nova
- python >=2.7
- shade
- ansible 2.x
-
Set OpenStack OS_* environment variables (required):
- Download OpenStack RC File (OpenStack>Compute>Access & Security>API Access)
cd flink-ansible folder
source rc_file
- (Test with
nova list
-
Create a new ssh key for ssh connetions to OpenStack instances with the name
flink
:- Import public key to OpenStack (OpenStack>Compute>Access & Security>Key Pairs>Import Key Pair)
- Copy private key with name=
flink
to ansible-flink/certificates - (the name of the private key file must match the variable
group_vars/all:ansible_ssh_private_key_file
and the name of the key name in OpenStack must match the variablegroup_vars/all:private_key_name
)
-
Create new Security Group with name=
flink
:- OpenStack>Compute>Access & Security>Security Groups>Create Security Group
- Add rule for ssh access (port 22)
- Add rule for flink ports (8081, 8080?, 6123?)
- (The os_server module will automatically add the security group with name
group_vars/all:sec_group
:flink
to the instances!)
- Start Playbook (Debug):
ansible-playbook -i hosts site.yml -K -vvv
- Start Playbook:
ansible-playbook -i hosts site.yml -K
- Creates new instances on the OpenStack server with the os_server module
- Saves the FloatingIPs in the host file
- Installs flink and all necessary dependencies on the instances
- (TODO) Setup and start the flink cluster
- (The content of the hosts file will be overwritten in every playbook call!)
Ansible Playbook Tutoiral
-
Target Section: defines on which hosts or host the playbook will be executed. # Defined in hosts file hosts: setuphost
-
Variable Section: define variables for the playbook. # Define vars vars: var1: 'Test variable'
-
Task Section: ordered list of module the playbook will run. #Define tasks tasks: - name: Test copy copy: scr=fileA dest=fileB - name: Install pkg apt: name=git state=present
Roles are a way to automatic load certain files:
- files
- templates
- tasks
- handlers
- vars
- defaults
- meta
Special syntax (start a role with parameters
roles:
- { role: ROLENAME, variable1: VAR1, variable2: VAR2 }
Ansible 2.0 offers a new set of OpenStack modules. Important for creating a Flink-Ansible instance is for example the os_server module:
os_server:
name: "{{iname}}"
state: present
image: ubuntu-14.04-trusty-server-cloudimg
flavor: m1.small
floating_ip_pools:
- float
key_name: flink
security_groups:
- default
- "{{sec_group}}"
nics:
- net-id: 8ba50f96-c076-4242-b975-1dbd83e318dd
Folder for variables (all
file):
- Setting the private keyfile for ssh connections (important)
- Setting ssh arguments to solve host key checking problems
ansible_ssh_private_key_file: certificates/flink
ansible_ssh_common_args: -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no