-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathansible-cli
More file actions
executable file
·77 lines (68 loc) · 4.33 KB
/
Copy pathansible-cli
File metadata and controls
executable file
·77 lines (68 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
set -e
if [ -n "$DEBUG" ]; then
set -x
fi
usage()
{
echo 'You should provide the following env vars:'
echo ''
echo "$0"
echo ' * `(ANSIBLE_MODULE)`: Module to use. Default: `shell`'
echo ' * `(ANSIBLE_MODULE_ARGS)`: Ad-hoc command to use with the module. Exemple: "echo foo"'
echo ' * `(ANSIBLE_TARGET_PATTERN)`: which managed nodes or groups you want to execute against. Default: `all`'
echo ' * `(ANSIBLE_LIMIT_HOSTS)`: select a subset of the inventory'
echo ' * `(SSH_PRIVATE_KEY)`: SSH key to use to connect on servers'
echo ' * `(SSH_PRIVATE_KEYS)`: SSH key array to use to connect on servers. Example: ["PRIVATE_KEY","PRIVATE_KEY"]'
echo ' * `(BASTION_URL)`: [DEPRECATED] SSH URL of the bastion server. Example: `admin@myserver.com`'
echo ' * `(SSH_JUMP_URL)`: SSH ProxyJump URL used with `ssh ProxyJump`. Example: `user1@Bastion1,user2@Bastion2`'
echo ' * `(EXTRA_ANSIBLE_VARS)`: [DEPRECATED] Ansible extra-vars, set additional variables, json dict format.'
echo ' * `(ANSIBLE_EXTRA_VARS)`: Ansible extra-vars, set additional variables, json dict format.'
echo ' * `(EXTRA_ANSIBLE_ARGS)`: [DEPRECATED] Additional ansible arguments'
echo ' * `(ANSIBLE_EXTRA_ARGS)`: Additional ansible arguments'
echo ' * `(ANSIBLE_REMOTE_USER)`: Ansible remote user. Default: `admin`.'
echo ' * `(DEBUG)`: Run in debug mode'
echo ''
echo 'ec2 vars:'
echo ' * `(AWS_INVENTORY)`: If the Amazon EC2 dynamic inventory needs to be used or not, can be either `true`, `false` or `auto`. `auto` checks if `AWS_ACCESS_KEY_ID` is set or not. Default: `auto`.'
echo ' * `(AWS_ACCESS_KEY_ID)`: Used by Amazon EC2 dynamic inventory'
echo ' * `(AWS_SECRET_ACCESS_KEY)`: Used by Amazon EC2 dynamic inventory'
echo ' * `(EC2_VPC_DESTINATION_VARIABLE)`: Can be either `ip_address` for public ip address or `private_ip_address`, see [ec2.ini](https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.ini). Default: `private_ip_address`.'
echo ''
echo 'azure_rm vars:'
echo ' * `(AZURE_INVENTORY)`: If the Azure dynamic inventory needs to be used or not, can be either `true`, `false` or `auto`. `auto` checks if `AZURE_SUBSCRIPTION_ID` is set or not. Default: `auto`.'
echo ' * `(AZURE_SUBSCRIPTION_ID)`: Used by Azure dynamic inventory'
echo ' * `(AZURE_TENANT_ID)`: Used by Azure dynamic inventory'
echo ' * `(AZURE_CLIENT_ID)`: Used by Azure dynamic inventory'
echo ' * `(AZURE_SECRET)`: Used by Azure dynamic inventory'
echo ' * `(AZURE_USE_PRIVATE_IP)`: Can be either `True` or `False`, see [azure_rm.py](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/azure_rm.py). Default: `True`.'
echo ''
echo 'gcp_compute vars:'
echo ' * `(GCP_INVENTORY)`: If the GCP dynamic inventory needs to be used or not, can be either `true`, `false` or `auto`. `auto` checks if `GCP_SERVICE_ACCOUNT_CONTENTS` is set or not. Default: `auto`.'
echo ' * `(GCP_SERVICE_ACCOUNT_CONTENTS)`: Used by GCP dynamic inventory. The GCP Service Account in JSON format.'
echo ' * `(GCP_USE_PRIVATE_IP)`: Can be either `True` or `False`. Default: `True`.'
echo ''
echo 'vmware_vm_inventory vars:'
echo ' * `(VMWARE_VM_INVENTORY)`: If the VMware Guest inventory needs to be used or not, can be either `true`, `false` or `auto`. `auto` checks if `VMWARE_SERVER` is set or not. Default: `auto`.'
echo ' * `(VMWARE_SERVER)`: Used by VMware Guest inventory. Name or IP address of vCenter server.'
echo ' * `(VMWARE_PORT)`: Used by VMware Guest inventory. Service port of vCenter server. Default: 443'
echo ' * `(VMWARE_USERNAME)`: Used by VMware Guest inventory. Name of vSphere user.'
echo ' * `(VMWARE_PASSWORD)`: Used by VMware Guest inventory. Password of vSphere user.'
echo ''
exit 1
}
if [ -n "$1" ]; then usage; fi
source /usr/bin/ansible-common.sh
# default
export ANSIBLE_MODULE=${ANSIBLE_MODULE:-shell}
export ANSIBLE_TARGET_PATTERN=${ANSIBLE_TARGET_PATTERN:-all}
echo "######################## Running ansible cli"
USER_PARAM=""
if [ "${ANSIBLE_REMOTE_USER}" != "empty" ]; then
USER_PARAM="-u ${ANSIBLE_REMOTE_USER}"
else
unset ANSIBLE_REMOTE_USER
fi
ansible --version
ansible -e cycloid_workdir=${CYCLOID_WORKDIR} ${ANSIBLE_TARGET_PATTERN} ${USER_PARAM} -m ${ANSIBLE_MODULE} ${ANSIBLE_EXTRA_ARGS}
exit $?