rifaterdemsahin / aif

Adaptive Intelligence Framework
5 stars 7 forks source link

Create Servers Via Ansible #2

Open rifaterdemsahin opened 6 years ago

rifaterdemsahin commented 6 years ago
rifaterdemsahin commented 6 years ago

Our YML File for Ansible http://docs.ansible.com/ansible/latest/guide_gce.html

name: Create instance(s) hosts: localhost connection: local gather_facts: no

vars: service_account_email: aif-318@developer.gserviceaccount.com credentials_file: /project.json project_id: adaptiveintelligenceframework machine_type: n1-standard-1 image: debian-7

tasks:

name: Launch instances gce: instance_names: dev machine_type: "{{ machine_type }}" image: "{{ image }}" service_account_email: "{{ service_account_email }}" credentials_file: "{{ credentials_file }}" project_id: "{{ project_id }}

rifaterdemsahin commented 6 years ago

image

https://console.cloud.google.com/compute/instances?project=adaptiveintelligenceframework

rifaterdemsahin commented 6 years ago

added to here image

rifaterdemsahin commented 6 years ago

image

Created keys folder to place the google Json image

rifaterdemsahin commented 6 years ago

/Users/rifaterdemsahin/keys/adaptiveintelligenceframework-f0833ece51c8.json

rifaterdemsahin commented 6 years ago

Note that when using the inventory script gce.py, you also need to populate the gce.ini file that you can find in the contrib/inventory directory of the ansible checkout.

image

image

rifaterdemsahin commented 6 years ago

image

rifaterdemsahin commented 6 years ago

under git repo on mac double ansible image

rifaterdemsahin commented 6 years ago

we have the google library now image

rifaterdemsahin commented 6 years ago

starters image

rifaterdemsahin commented 6 years ago

image

rifaterdemsahin commented 6 years ago

no change after path setting image

rifaterdemsahin commented 6 years ago

image

rifaterdemsahin commented 6 years ago

https://libcloud.apache.org/blog/2015/02/18/libcloud-0-17-0-released.html

Sudo force image

rifaterdemsahin commented 6 years ago

Started to get meaning full errors

Erdems-MacBook-Pro:inventory rifaterdemsahin$ ./gce.py --list Traceback (most recent call last): File "./gce.py", line 508, in GceInventory() File "./gce.py", line 170, in init self.driver = self.get_gce_driver() File "./gce.py", line 318, in get_gce_driver gce = get_driver(Provider.GCE)(*args, **kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 878, in init raise ValueError('Project name must be specified using ' ValueError: Project name must be specified using "project" keyword. Erdems-MacBook-Pro:inventory rifaterdemsahin$

rifaterdemsahin commented 6 years ago

export PYTHONPATH=/Library/Python/2.7/site-packages/

Erdems-MacBook-Pro:lib rifaterdemsahin$ ansible --version ansible 2.4.3.0 config file = None configured module search path = [u'/Users/rifaterdemsahin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /Library/Python/2.7/site-packages/ansible executable location = /usr/local/bin/ansible python version = 2.7.10 (default, Jul 15 2017, 17:16:57) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]

rifaterdemsahin commented 6 years ago

now under site-packages and path reset image

rifaterdemsahin commented 6 years ago

error changed to datacenter image

rifaterdemsahin commented 6 years ago

after empty datacenter image

Traceback (most recent call last): File "./gce.py", line 508, in GceInventory() File "./gce.py", line 170, in init self.driver = self.get_gce_driver() File "./gce.py", line 318, in get_gce_driver gce = get_driver(Provider.GCE)(*args, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 887, in init super(GCENodeDriver, self).init(user_id, key, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/base.py", line 651, in init api_version=api_version, *kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 1013, in init self.connection = self.connectionCls(args, conn_kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 75, in init kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 619, in init user_id, key, self.scopes, kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 463, in init raise GoogleAuthError('PyCrypto library required for ' libcloud.common.google.GoogleAuthError: 'PyCrypto library required for Service Account Authentication.'** Erdems-MacBook-Pro:inventory rifaterdemsahin$

rifaterdemsahin commented 6 years ago

Erdems-MacBook-Pro:inventory rifaterdemsahin$ sudo pip install pycrypto Password: The directory '/Users/rifaterdemsahin/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/rifaterdemsahin/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting pycrypto Downloading pycrypto-2.6.1.tar.gz (446kB) 100% |████████████████████████████████| 450kB 1.1MB/s Installing collected packages: pycrypto Running setup.py install for pycrypto ... done Successfully installed pycrypto-2.6.1 Erdems-MacBook-Pro:inventory rifaterdemsahin$

rifaterdemsahin commented 6 years ago

Erdems-MacBook-Pro:inventory rifaterdemsahin$ ./gce.py --list Traceback (most recent call last): File "./gce.py", line 508, in GceInventory() File "./gce.py", line 170, in init self.driver = self.get_gce_driver() File "./gce.py", line 318, in get_gce_driver gce = get_driver(Provider.GCE)(*args, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 887, in init super(GCENodeDriver, self).init(user_id, key, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/base.py", line 651, in init api_version=api_version, *kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 1013, in init self.connection = self.connectionCls(args, conn_kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 75, in init kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 627, in init self.token_info = self.auth_conn.get_new_token() File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 516, in get_new_token return self._token_request(request) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 352, in _token_request raise GoogleAuthError('Invalid authorization response, please ' libcloud.common.google.GoogleAuthError: 'Invalid authorization response, please check your credentials.'

rifaterdemsahin commented 6 years ago

image

rifaterdemsahin commented 6 years ago

image

rifaterdemsahin commented 6 years ago

Last login: Wed Mar 7 18:39:27 on ttys001 Erdems-MBP:~ rifaterdemsahin$ cd /Library/Python/2.7/site-packages/ Erdems-MBP:site-packages rifaterdemsahin$ sudo nano secrets.py Password: Erdems-MBP:site-packages rifaterdemsahin$ more secrets.py GCE_PARAMS = ('aif-318@project.googleusercontent.com', '/Users/rifaterdemsahin/keys/adaptiveintelligenceframework-f0833ece51c8.json') GCE_KEYWORD_PARAMS = {'project': 'adaptiveintelligenceframework', 'datacenter': ''}

maybe datacenter ?

setting defaults here image

europe-west1

updated version secrets.py

GCE_PARAMS = ('aif-318@project.googleusercontent.com', '/Users/rifaterdemsahin/keys/adaptiveintelligenceframework-f0833ece51c8.json') GCE_KEYWORD_PARAMS = {'project': 'adaptiveintelligenceframework', 'datacenter': 'europe-west1'}

rifaterdemsahin commented 6 years ago

same error

Erdems-MacBook-Pro:inventory rifaterdemsahin$ ./gce.py --list Traceback (most recent call last): File "./gce.py", line 508, in GceInventory() File "./gce.py", line 170, in init self.driver = self.get_gce_driver() File "./gce.py", line 318, in get_gce_driver gce = get_driver(Provider.GCE)(*args, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 887, in init super(GCENodeDriver, self).init(user_id, key, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/base.py", line 651, in init api_version=api_version, *kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 1013, in init self.connection = self.connectionCls(args, conn_kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 75, in init kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 627, in init self.token_info = self.auth_conn.get_new_token() File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 516, in get_new_token return self._token_request(request) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 352, in _token_request raise GoogleAuthError('Invalid authorization response, please ' libcloud.common.google.GoogleAuthError: 'Invalid authorization response, please check your credentials.'

rifaterdemsahin commented 6 years ago

Could you look at the files in the ansible/inventory/gce/hosts/ folder? There should be project.json and secrets.py, check if they seem correct, maybe post them here, but without any sensitive data (emails, keys, ids..). Also try to run ./ansible/inventory/gce/hosts/gce.py and see if it prints any error. And please post the output of the timedatectl command.

image

rifaterdemsahin commented 6 years ago

export GCE_CREDENTIALS_FILE_PATH=/Users/rifaterdemsahin/keys/adaptiveintelligenceframework-f0833ece51c8.json

set et

rifaterdemsahin commented 6 years ago

Erdems-MacBook-Pro:inventory rifaterdemsahin$ export GCE_CREDENTIALS_FILE_PATH=/Users/rifaterdemsahin/keys/adaptiveintelligenceframework-f0833ece51c8.json Erdems-MacBook-Pro:inventory rifaterdemsahin$ Erdems-MacBook-Pro:inventory rifaterdemsahin$ ./gce.py --list Traceback (most recent call last): File "./gce.py", line 508, in GceInventory() File "./gce.py", line 170, in init self.driver = self.get_gce_driver() File "./gce.py", line 318, in get_gce_driver gce = get_driver(Provider.GCE)(*args, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 887, in init super(GCENodeDriver, self).init(user_id, key, kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/base.py", line 651, in init api_version=api_version, *kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 1013, in init self.connection = self.connectionCls(args, conn_kwargs) File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py", line 75, in init kwargs) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 627, in init self.token_info = self.auth_conn.get_new_token() File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 516, in get_new_token return self._token_request(request) File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line 352, in _token_request raise GoogleAuthError('Invalid authorization response, please ' libcloud.common.google.GoogleAuthError: 'Invalid authorization response, please check your credentials.' Erdems-MacBook-Pro:inventory rifaterdemsahin$