Class: Kitchen::Yansible::Tools::Install::Darwin
Constant Summary
BINARY_DEFAULT_PREFIX, BINARY_INSTALL_PREFIX
Instance Method Summary
collapse
#alternatives_command, #ansible_version, #get_python_version, #initialize, #install_package, #local_install, make, #package_manager, #pip_required_packages, #pip_version, #python_version_size, #remote_install, #ruby_alternatives, #update_cache
Methods included from Exec
#check_command, #command_exists, #detect_platform, #execute_local_command, #local_command_exists, #local_command_path, #print_cmd_error, #print_cmd_parameters, #sudo, #sudo_env, #unindent
Instance Method Details
#ansible_alternatives(install_prefix, sandbox_path) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 144
def ansible_alternatives(install_prefix, sandbox_path)
"""
#{command_exists("#{sandbox_path}/venv/bin/ansible")} && {
ansibleCommands=( \\
ansible \\
ansible-config \\
ansible-connection \\
ansible-console \\
ansible-doc \\
ansible-galaxy \\
ansible-inventory \\
ansible-playbook \\
ansible-pull \\
ansible-test \\
ansible-vault \\
)
for ansibleCommand in \"${ansibleCommands[@]}\"; do
#{sudo('ln -sf')} #{sandbox_path}/venv/bin/${ansibleCommand} #{install_prefix}/${ansibleCommand}
done
} || {
echo '===> Ansible is not installed, exiting now. <==='
exit 1
}
echo 'Check alternatives validity'
#{command_exists("#{install_prefix}/ansible")} || {
echo '===> Ansible alternative is incorrectly installed, exiting now. <==='
exit 1
}
"""
end
|
#install_ansible_pip(sandbox_path) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 124
def install_ansible_pip(sandbox_path)
"""
installAnsiblePip () {
echo \"Installing Ansible via Pip\"
VENV_MODULE=virtualenv
echo ${ANSIBLE_PYTHON_INTERPRETER} | grep 3 &>/dev/null && {
VENV_MODULE=venv
}
test -f #{sandbox_path}/venv/bin/pip || {
mkdir -p #{sandbox_path}
${ANSIBLE_PYTHON_INTERPRETER} -m ${VENV_MODULE} #{sandbox_path}/venv
#{sandbox_path}/venv/bin/pip install $PIP_ARGS --upgrade pip setuptools
}
#{sandbox_path}/venv/bin/pip install $PIP_ARGS #{pip_required_packages.join(' ')}
#{ansible_alternatives(BINARY_INSTALL_PREFIX, sandbox_path)}
}
"""
end
|
#install_python ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 52
def install_python
"""
installPython () {
PYTHON_CMD='/usr/bin/python3'
#{command_exists("${PYTHON_CMD}")} || {
PYTHON_CMD='/usr/bin/python'
}
grep 'ANSIBLE_PYTHON_INTERPRETER' ~/.profile &> /dev/null || {
echo \"ANSIBLE_PYTHON_INTERPRETER=${PYTHON_CMD}\" >> ~/.profile
echo 'export ANSIBLE_PYTHON_INTERPRETER' >> ~/.profile
}
#{sudo('grep')} ANSIBLE_PYTHON_INTERPRETER /etc/sudoers.d/ansible &> /dev/null || {
#{sudo('echo')} 'Defaults env_keep += \"ANSIBLE_PYTHON_INTERPRETER\"' | #{sudo('tee')} -a /etc/sudoers.d/ansible
}
source ~/.profile
}
"""
end
|
#install_ruby ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 72
def install_ruby
"""
installRuby () {
searchAlternatives ruby
echo 'Install Busser'
#{sudo('gem')} list | grep busser || {
#{sudo('gem')} install busser
}
test -d /opt/chef/embedded/bin || {
#{sudo('mkdir')} -p /opt/chef/embedded/bin
}
echo 'Making links for Chef'
for binary in ruby gem busser; do
test -L /opt/chef/embedded/bin/${binary} || {
#{sudo('ln')} -sf $(command -v ${binary}) /opt/chef/embedded/bin/${binary}
}
done
}
"""
end
|
#install_virtualenv ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 93
def install_virtualenv
"""
installVirtualenv () {
echo 'Checking Virtualenv installation.'
${ANSIBLE_PYTHON_INTERPRETER} -c 'help(\"modules\")'|grep ' pip ' &>/dev/null || {
${ANSIBLE_PYTHON_INTERPRETER} -m ensurepip
}
${ANSIBLE_PYTHON_INTERPRETER} -m pip list|grep 'virtualenv' &>/dev/null || {
${ANSIBLE_PYTHON_INTERPRETER} -m pip install --user virtualenv
}
}
"""
end
|
#preinstall_command ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 42
def preinstall_command
"""
#{update_path}
preInstall () {
updatePath
}
"""
end
|
#search_alternatives ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 26
def search_alternatives
"""
searchAlternatives() {
binaryCmd=$1
test -n \"${2}\" && installPrefix=\"${2}\" || installPrefix=#{BINARY_DEFAULT_PREFIX}
#{command_exists("${binaryCmd}")} || {
alternateCmd=$(ls -1A ${installPrefix}/${binaryCmd}*|sort -r|head -n1)
test -n \"${alternateCmd}\" && {
echo \"Attempt to install '${alternateCmd}' as an alternative.\"
#{sudo('ln')} -sf \"${alternateCmd}\" #{BINARY_DEFAULT_PREFIX}/${binaryCmd}
}
}
}
"""
end
|
#update_path ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/kitchen-yansible/tools/install/darwin.rb', line 108
def update_path
"""
updatePath () {
#{sudo('grep')} secure_path /etc/sudoers.d/ansible &> /dev/null || {
#{sudo('echo')} 'Defaults secure_path = /usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' | #{sudo('tee')} -a /etc/sudoers.d/ansible
}
grep 'PATH=/usr/local/bin:$PATH' ~/.profile &> /dev/null || {
echo 'PATH=/usr/local/bin:$PATH' >> ~/.profile
echo 'export PATH' >> ~/.profile
}
source ~/.profile
}
"""
end
|