[PYTHON] When the target is Ubuntu 16.04 in Ansible

A memorandum for myself. Procedure when targeting Ubuntu 16.04 with Ansible.

Missing python2

Ubuntu 16.04 does not have python2 because it is python3 by default. In other words. All modules don't work.

Forcibly insert python2

The target IP address is tentative.

user@ubuntu$ cat >> hosts <<__EOT__
[targets]
172.16.130.41
172.16.129.118
__EOT__

user@ubuntu$ ansible -v all -i hosts -m raw -a "sudo apt -y install python"
No config file found; using defaults
172.16.129.118 | SUCCESS | rc=0 >>
sudo: unable to resolve host test.xff: Connection timed out
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-36 linux-headers-4.4.0-36-generic
  linux-image-4.4.0-36-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python-minimal
  python2.7 python2.7-minimal
Suggested packages:
  python-doc python-tk python2.7-doc binfmt-support
The following NEW packages will be installed:
  libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python
  python-minimal python2.7 python2.7-minimal
0 upgraded, 7 newly installed, 0 to remove and 16 not upgraded.
Need to get 3,907 kB of archives.
After this operation, 16.6 MB of additional disk space will be used.
Get:1 http://172.16.128.11/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1~16.04 [339 kB]
Get:2 http://172.16.128.11/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1~16.04 [1,294 kB]
Get:3 http://172.16.128.11/ubuntu xenial/main amd64 python-minimal amd64 2.7.11-1 [28.2 kB]
Get:4 http://172.16.128.11/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1~16.04 [1,877 kB]
Get:5 http://172.16.128.11/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1~16.04 [224 kB]
Get:6 http://172.16.128.11/ubuntu xenial/main amd64 libpython-stdlib amd64 2.7.11-1 [7,656 B]
Get:7 http://172.16.128.11/ubuntu xenial/main amd64 python amd64 2.7.11-1 [137 kB]
Fetched 3,907 kB in 0s (13.5 MB/s)
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database ... 114255 files and directories currently installed.)
Preparing to unpack .../libpython2.7-minimal_2.7.12-1~16.04_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.12-1~16.04) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../python2.7-minimal_2.7.12-1~16.04_amd64.deb ...
Unpacking python2.7-minimal (2.7.12-1~16.04) ...
Selecting previously unselected package python-minimal.
Preparing to unpack .../python-minimal_2.7.11-1_amd64.deb ...
Unpacking python-minimal (2.7.11-1) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack .../libpython2.7-stdlib_2.7.12-1~16.04_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.12-1~16.04) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../python2.7_2.7.12-1~16.04_amd64.deb ...
Unpacking python2.7 (2.7.12-1~16.04) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../libpython-stdlib_2.7.11-1_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.11-1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Setting up libpython2.7-minimal:amd64 (2.7.12-1~16.04) ...
Setting up python2.7-minimal (2.7.12-1~16.04) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up python-minimal (2.7.11-1) ...
Selecting previously unselected package python.
(Reading database ... 115001 files and directories currently installed.)
Preparing to unpack .../python_2.7.11-1_amd64.deb ...
Unpacking python (2.7.11-1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libpython2.7-stdlib:amd64 (2.7.12-1~16.04) ...
Setting up python2.7 (2.7.12-1~16.04) ...
Setting up libpython-stdlib:amd64 (2.7.11-1) ...
Setting up python (2.7.11-1) ...
Shared connection to 172.16.129.118 closed.


172.16.130.41 | SUCCESS | rc=0 >>
sudo: unable to resolve host test2: Connection timed out
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python-minimal
  python2.7 python2.7-minimal
Suggested packages:
  python-doc python-tk python2.7-doc binutils binfmt-support
The following NEW packages will be installed:
  libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python
  python-minimal python2.7 python2.7-minimal
0 upgraded, 7 newly installed, 0 to remove and 4 not upgraded.
Need to get 3,907 kB of archives.
After this operation, 16.6 MB of additional disk space will be used.
Get:1 http://172.16.128.11/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1~16.04 [339 kB]
Get:2 http://172.16.128.11/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1~16.04 [1,294 kB]
Get:3 http://172.16.128.11/ubuntu xenial/main amd64 python-minimal amd64 2.7.11-1 [28.2 kB]
Get:4 http://172.16.128.11/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1~16.04 [1,877 kB]
Get:5 http://172.16.128.11/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1~16.04 [224 kB]
Get:6 http://172.16.128.11/ubuntu xenial/main amd64 libpython-stdlib amd64 2.7.11-1 [7,656 B]
Get:7 http://172.16.128.11/ubuntu xenial/main amd64 python amd64 2.7.11-1 [137 kB]
Fetched 3,907 kB in 0s (34.9 MB/s)
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database ... 53631 files and directories currently installed.)
Preparing to unpack .../libpython2.7-minimal_2.7.12-1~16.04_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.12-1~16.04) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../python2.7-minimal_2.7.12-1~16.04_amd64.deb ...
Unpacking python2.7-minimal (2.7.12-1~16.04) ...
Selecting previously unselected package python-minimal.
Preparing to unpack .../python-minimal_2.7.11-1_amd64.deb ...
Unpacking python-minimal (2.7.11-1) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack .../libpython2.7-stdlib_2.7.12-1~16.04_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.12-1~16.04) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../python2.7_2.7.12-1~16.04_amd64.deb ...
Unpacking python2.7 (2.7.12-1~16.04) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../libpython-stdlib_2.7.11-1_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.11-1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Setting up libpython2.7-minimal:amd64 (2.7.12-1~16.04) ...
Setting up python2.7-minimal (2.7.12-1~16.04) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up python-minimal (2.7.11-1) ...
Selecting previously unselected package python.
(Reading database ... 54377 files and directories currently installed.)
Preparing to unpack .../python_2.7.11-1_amd64.deb ...
Unpacking python (2.7.11-1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libpython2.7-stdlib:amd64 (2.7.12-1~16.04) ...
Setting up python2.7 (2.7.12-1~16.04) ...
Setting up libpython-stdlib:amd64 (2.7.11-1) ...
Setting up python (2.7.11-1) ...
Shared connection to 172.16.130.41 closed.

user@ubuntu$ ansible -v all -i hosts -m ping
172.16.129.118 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
172.16.130.41 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
user@ubuntu$ ansible -v all -i hosts -m command -a uptime
172.16.129.118 | SUCCESS | rc=0 >>
 10:43:40 up  1:52,  2 users,  load average: 0.00, 0.02, 0.00

172.16.130.41 | SUCCESS | rc=0 >>
 19:43:40 up  1:52,  1 user,  load average: 0.12, 0.10, 0.05

When doing with playbook

- hosts: all
  gather_facts: no
  remote_user: ubuntu
  become: yes
  become_user: root
  become_method: sudo
  
  pre_tasks:
    - raw: apt -y install python

Recommended Posts

When the target is Ubuntu 16.04 in Ansible
When the selected object in bpy.context.selected_objects is not returned
When the node disappears in rqt_graph
[Golang] "package exec is not in GOROOT" when executing the test
Build Python environment on Ubuntu (when pip is not the default)
The solution when an empty object is returned in go's json.Marshal
Animate what happens in frequency space when the Nyquist frequency is exceeded
What to do when the value type is ambiguous in Python?
Behavior when returning in the with block
What is "mahjong" in the Python library? ??
When the previous graph remains in Seaborn
Is there NaN in the pandas DataFrame?
The date is displayed incorrectly in matplotlib.
What to do when the result downloaded via scrapy is in English
Notify using Notification Center when the execution environment is macOS in Python
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
CPU usage is 100% when using pygame on Ubuntu 16.04
[pandas] When specifying the default Index label in the at method, "" is not required
Pipfile is not created in the current directory
What is wheezy in the Docker Python image?
When searching is not working in GAE's Datastore
About the difference between "==" and "is" in python
[Django] Error when SlugField is specified in .filter ()
Precautions when installing packages in the conda environment
Differences in the behavior of each LL language when the list index is skipped
[For beginners] Unexpected behavior if "\" is included when setting the path in Python
When the axis and label overlap in matplotlib
When a file is placed in the shared folder of Raspberry Pi, the process is executed.
[Solution] When inserting "0001" into the column of string in sqlite3, it is entered as "1".
What to do when is not in the sudoers file.This incident will be reported.
What to do when only the window is displayed and nothing is displayed in pygame Note
When a local variable with the same name as a global variable is defined in the function
Check if the string is a number in python
How to run the Ansible module added in Ansible Tower
Linux is something like that in the first place
Initial settings when using the foursquare API in python
When displaying RichTextField in Wagtail, <p> tag is attached.
What is the domain attribute written in Plotly's Layout?
Check if it is Unix in the scripting language
Note when putting lxml of python package in ubuntu 14.04
Find the part that is 575 from Wikipedia in Python
Determine if an attribute is defined in the object
Check if it is Unix in the scripting language
When "ERROR: HTTP is not supported." Is displayed in mpsyt
When you think the update of ManjaroLinux is strange
Creating a list when the nomenclature is a fixed time
When reading an image with SimpleITK, there is a problem if there is Japanese in the path
About the matter that nosetests does not pass when __init__.py is created in the project directory
R in Anaconda (in Ubuntu 14.04)
When a character string of a certain series is in the Key of the dictionary, the character string is converted to the Value of the dictionary.
How to delete "(base)" that appears in the terminal when Anaconda is installed on Mac
Beep in Python (Ubuntu)
When the variable name conflicts with the Devaga command in pdb
Test.py is not reflected on the web server in Python3.
[Pandas] If the first row data is in the header in DataFrame
Master the type in Python? (When should type check be done)
Automatically get the port where Arduino is stuck in Python
Is there a bias in the numbers that appear in the Fibonacci numbers?
Record when Elementary OS (Hera) is installed in Dell XPS 13 (7390)
Solve the Japanese problem when using the CSV module in Python.
Find out how many each character is in the string.