Skip to content

Commit 9d46bb2

Browse files
authored
Merge pull request #686 from ystia/feature/GH-648-ansible-version
Feature/gh 648 ansible version
2 parents 8fc605e + 2419ab7 commit 9d46bb2

File tree

13 files changed

+65
-41
lines changed

13 files changed

+65
-41
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## UNRELEASED
44

5+
### DEPENDENCIES
6+
7+
* The orchestrator requires now at least Ansible 2.10.0 (upgrade from 2.7.9 introduced in [GH-648](https://github.com/ystia/yorc/issues/648))
8+
59
### FEATURES
610

711
* Added an ElasticSearch store for events and logs ([GH-658](https://github.com/ystia/yorc/issues/658))
@@ -13,6 +17,7 @@
1317

1418
### ENHANCEMENTS
1519

20+
* Upgrade Ansible version from 2.7.9 to 2.10.0 ([GH-648](https://github.com/ystia/yorc/issues/648))
1621
* Alien4Cloud download URL change ([GH-637](https://github.com/ystia/yorc/issues/637))
1722
* Enhance logs and events long-polling performances on file storage ([GH-654](https://github.com/ystia/yorc/issues/654))
1823

Binary file not shown.

commands/bootstrap/setup.go

+21
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ func installDependencies(workingDirectoryPath string) error {
422422
return err
423423
}
424424

425+
// Install paramiko
426+
if err := installParamiko(); err != nil {
427+
return err
428+
}
429+
425430
// Download Consul
426431
overwrite := (previousBootstrapVersion.Consul != consulVersion)
427432
if err := downloadUnzip(inputValues.Consul.DownloadURL, "consul.zip", workingDirectoryPath, overwrite); err != nil {
@@ -546,6 +551,22 @@ func installAnsible(version string) error {
546551
return err
547552
}
548553

554+
// installParamiko installs Paramiko needed when openSSH is not used
555+
// Install using pip3 if available else using pip
556+
func installParamiko() error {
557+
pipCmd, err := getPipCmd()
558+
if err != nil {
559+
return err
560+
}
561+
562+
// Installing ansible
563+
cmd := exec.Command(pipCmd, "install", "--upgrade", "paramiko")
564+
cmd.Stdout = os.Stdout
565+
cmd.Stderr = os.Stderr
566+
err = cmd.Run()
567+
return err
568+
}
569+
549570
// getPipModuleInstalledVersion retruns the version of an installed pip module.
550571
// Returns an error if the module is not installed
551572
func getPipModuleInstalledVersion(pipCmd, module string) (string, error) {

doc/bootstrap.rst

+10-16
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ It requires the following packages to be installed on the local host:
5858
* wget
5959

6060
This basic installation on the local host will attempt to install without sudo privileges
61-
python ansible module |ansible_version| if needed as well as python packages
61+
python ansible module |ansible_version| if needed as well as paramiko and python packages
6262
MarkupSafe, jinja2, PyYAML, six, cryptography, setuptools.
6363
So if this ansible module or python packages are not yet installed on the local host,
6464
you could either add them yourself, with sudo privileges, running for example:
@@ -279,12 +279,12 @@ for example :
279279
280280
The bootstrap configuration file can be also be used to define Ansible Inventory
281281
configuration parameters.
282-
This is needed for example if remote hosts have python3 installed by default and not python,
283-
like on Ubuntu 18+.
282+
This is needed for example if you want to use on target hosts a python version
283+
different from the one automatically selected by Ansible.
284284

285285
In this case, you can add in the bootstrap configuration file, a section allowing
286286
to configure an Ansible behavioral inventory parameter that will allow to specify
287-
which python interpreter could be used by Ansible on remote hosts, as described in
287+
which python interpreter could be used by Ansible on target hosts, as described in
288288
:ref:`Ansible Inventory Configuration section <option_ansible_inventory_cfg>`.
289289

290290
This would give for example in the bootstrap configuration file:
@@ -343,14 +343,12 @@ Example of a Google Cloud deployment configuration file
343343
344344
.. _yorc_google_example_ubuntu_section:
345345

346-
Example of a Google Cloud deployment configuration with Ubuntu 19.04 on-demand compute
347-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346+
Example of a Google Cloud deployment configuration enforcing the use of python3
347+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348348

349-
In this example, on-demand compute instances run Ubuntu 19.04 on which python3
350-
is installed by default (and not python).
351-
In this case, a specific Ansible behavioral inventory parameter
352-
``ansible_python_interpreter`` must be defined so that Ansible is able to find
353-
this python interpreter on the remote hosts.
349+
In this example, a specific Ansible behavioral inventory parameter
350+
``ansible_python_interpreter`` is defined so that Ansible will use the specified
351+
python interpreter on the target hosts.
354352

355353
.. code-block:: YAML
356354
@@ -375,11 +373,7 @@ this python interpreter on the remote hosts.
375373
project: myproject
376374
ansible:
377375
inventory:
378-
# Remote host run Ubuntu 19.04, using python3.
379-
# Defining here the Ansible behavioral inventory parameter ansible_python_interpreter
380-
# pointing to python3.
381-
# This is required or Ansible will attempt to use python on the remote host
382-
# which will fail as python is not installed by default.
376+
# Enforce the use of /usr/bin/python3 by Ansible on target hosts
383377
"target_hosts:vars":
384378
- ansible_python_interpreter=/usr/bin/python3
385379
address:

doc/configuration.rst

+4-9
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ can be any parameter specific to your ansible playbooks, or `behavioral inventor
489489
parameters <https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#list-of-behavioral-inventory-parameters>`_
490490
describing how Ansible interacts with remote hosts.
491491

492-
For example, for Ansible to use python3 on remote hosts, you must define
492+
For example, for Ansible to use a given python interpreter on target hosts, you must define
493493
the Ansible behavioral inventory parameter ``ansible_python_interpreter``
494494
in the Ansible inventory Yorc configuration, like below in Yaml:
495495

@@ -503,16 +503,11 @@ in the Ansible inventory Yorc configuration, like below in Yaml:
503503
By default, the Orchestrator will define :
504504

505505
* an inventory group ``target_hosts`` containing the list of remote hosts, and its
506-
associated variable group ``target_hosts:vars`` configuring by default this
507-
behavioral parameter:
506+
associated variable group ``target_hosts:vars`` configuring by default these
507+
behavioral parameters:
508508

509509
* ``ansible_ssh_common_args="-o ConnectionAttempts=20"``
510-
511-
* an inventory group ``hosted_operations`` and its associated variable group ``hosted_operations:vars``
512-
for operations that are executed on the orchestrator host, configuring by default
513-
this behavioral parameter:
514-
515-
* ``ansible_python_interpreter=/usr/bin/env python``
510+
* ``ansible_python_interpreter="auto_silent"``
516511

517512
.. warning::
518513
Settings defined by the user take precedence over settings defined by the

doc/install.rst

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Now you can proceed with the installation of softwares used by Yorc.
6363
.. parsed-literal::
6464
6565
sudo pip install ansible==\ |ansible_version|
66+
sudo pip install paramiko
6667
wget \https://releases.hashicorp.com/consul/\ |consul_version|\ /consul\_\ |consul_version|\ _linux_amd64.zip
6768
sudo unzip consul\_\ |consul_version|\ _linux_amd64.zip -d /usr/local/bin
6869
wget \https://releases.hashicorp.com/terraform/\ |terraform_version|\ /terraform\_\ |terraform_version|\ _linux_amd64.zip

doc/tosca.rst

+3-8
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,9 @@ In order to let Yorc interact with Docker to manage sandboxes some requirements
215215
Yorc uses standard Docker's APIs so ``DOCKER_HOST`` and ``DOCKER_CERT_PATH`` environment variables could be used
216216
to configure the way Yorc interacts with Docker.
217217

218-
In order to execute operations on containers, either the following requirements
219-
should be met on Docker images used as sandboxes:
220-
221-
* the ``/usr/bin/env`` command should be present
222-
* a python 2 interpreter compatible with ansible |ansible_version| should be available as the ``python`` command
223-
224-
or Yorc configuration should provide a python interpreter path through the Ansible
225-
behavioral inventory parameter ``ansible_python_interpreter``, like below in a Yaml
218+
To execute operations on containers, Ansible will by default detect the python interpreter to use
219+
as described in `Ansible documentation <https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html>`_ section ``auto_silent``.
220+
To provide yourself a python interpreter path, use the Ansible behavioral inventory parameter ``ansible_python_interpreter``, like below in a Yaml
226221
Yorc configuration excerpt specifying to use python3 :
227222

228223
.. code-block:: YAML

doc/upgrade.rst

+16
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ feature requires to have the ``management`` ACL. It is possible to disable this
3434

3535
.. note:: A rolling upgrade without interruption feature is planned for future versions.
3636

37+
.. _yorc_upgrades_410_section:
38+
39+
Upgrading to Yorc 4.1.0
40+
-----------------------
41+
42+
Ansible
43+
~~~~~~~
44+
45+
Upgrade Ansible to version 2.10.0:
46+
47+
.. code-block:: bash
48+
49+
sudo pip uninstall ansible
50+
sudo pip install ansible==2.10.0
51+
sudo pip install paramiko
52+
3753
.. _yorc_upgrades_320_section:
3854

3955
Upgrading to Yorc 3.2.0

pkg/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG TF_GOOGLE_PLUGIN_VERSION
77
ARG TF_OPENSTACK_PLUGIN_VERSION
88
# Update terraform default when possible
99
ENV TERRAFORM_VERSION ${TERRAFORM_VERSION:-0.11.8}
10-
ENV ANSIBLE_VERSION ${ANSIBLE_VERSION:-2.7.9}
10+
ENV ANSIBLE_VERSION ${ANSIBLE_VERSION:-2.10.0}
1111
ENV TF_CONSUL_PLUGIN_VERSION ${TF_CONSUL_PLUGIN_VERSION:-2.1.0}
1212
ENV TF_AWS_PLUGIN_VERSION ${TF_AWS_PLUGIN_VERSION:-1.36.0}
1313
ENV TF_GOOGLE_PLUGIN_VERSION ${TF_GOOGLE_PLUGIN_VERSION:-1.18.0}

prov/ansible/execution.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const ansibleConfigDefaultsHeader = "defaults"
6464
const ansibleInventoryHostsHeader = "target_hosts"
6565
const ansibleInventoryHostedHeader = "hosted_operations"
6666
const ansibleInventoryHostsVarsHeader = ansibleInventoryHostsHeader + ":vars"
67-
const ansibleInventoryHostedVarsHeader = ansibleInventoryHostedHeader + ":vars"
6867

6968
var ansibleDefaultConfig = map[string]map[string]string{
7069
ansibleConfigDefaultsHeader: map[string]string{
@@ -83,9 +82,7 @@ var ansibleFactCaching = map[string]string{
8382
var ansibleInventoryConfig = map[string][]string{
8483
ansibleInventoryHostsVarsHeader: []string{
8584
"ansible_ssh_common_args=\"-o ConnectionAttempts=20\"",
86-
},
87-
ansibleInventoryHostedVarsHeader: []string{
88-
"ansible_python_interpreter=/usr/bin/env python",
85+
"ansible_python_interpreter=\"auto_silent\"",
8986
},
9087
}
9188

prov/ansible/yaml_output.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func endTaskSectionAndLogTaskResult(ansibleTask *ansibleTaskContext) {
166166
// internal implementation doesn't have to appear in Consul logs.
167167
// Logs for this script will be added in Consul.
168168
// Logs of other internal tasks are skipped.
169-
if ansibleTask.taskName == "command" {
169+
if ansibleTask.taskName == "command" || ansibleTask.taskName == "shell" {
170170
logScriptTaskResult(ansibleTask)
171171
}
172172
}

testdata/infra/openstack/yorc.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ resource "null_resource" "yorc-server-provisioning" {
138138
"sudo yum install -q -y python2-pip nfs-utils autofs",
139139
"cd /tmp && wget -q https://releases.hashicorp.com/terraform/0.9.11/terraform_0.9.11_linux_amd64.zip && sudo unzip /tmp/terraform_0.9.11_linux_amd64.zip -d /usr/local/bin",
140140
"sudo -H pip install -q pip --upgrade",
141-
"sudo -H pip install -q ansible==2.7.9",
141+
"sudo -H pip install -q ansible==2.10.0",
142142
"mv /tmp/config.yorc.json ~/config.yorc.json",
143143
"echo -e '/- /etc/auto.direct\n' | sudo tee /etc/auto.master > /dev/null",
144144
"cat /tmp/auto.yorc | sudo tee /etc/auto.direct > /dev/null",

versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ yorc_version: 4.1.0-SNAPSHOT
33
alien4cloud_version: 2.2.0
44
consul_version: 1.2.3
55
terraform_version: 0.11.8
6-
ansible_version: 2.7.9
6+
ansible_version: 2.10.0
77
tf_consul_plugin_version: 2.1.0
88
tf_aws_plugin_version: 1.36.0
99
tf_openstack_plugin_version: 1.9.0

0 commit comments

Comments
 (0)