Coder Social home page Coder Social logo

ansiblebook / ansiblebook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lorin/ansiblebook

459.0 50.0 316.0 904 KB

Code samples from the book "Ansible: Up and Running"

Home Page: http://ansiblebook.com

HTML 89.19% Python 0.86% Shell 0.41% Makefile 0.34% JavaScript 0.16% Jinja 1.93% Dockerfile 0.01% Ruby 0.06% HCL 0.45% Perl 0.05% YAML 6.55%

ansiblebook's Introduction

Ansible: Up and Running (3rd edition) code samples

This repository contains code samples from Ansible: Up and Running, 3rd. Ed. ISBN:978-1-098-10915-8, organized by book chapter.

The book is published by O'Reilly https://oreil.ly/lOxWu

Note that most chapters have a single subdirectory named playbooks. I did this so that the directory structure of the code would match the directory structure in the book, since the book always assumes a playbooks directory.

If you encounter any problems with these samples, please submit a GitHub issue or a pull request against this repository.

Readers of the Early Release on the O'Reilly site should checkout the branch 3rd-edition.

ansiblebook's People

Contributors

andypb avatar bbaassssiiee avatar brlin-tw avatar jonleibowitz avatar lekum avatar lorin avatar manhtai avatar n-x avatar nmusatti avatar pfuntner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansiblebook's Issues

Issues running 'vagrant up' for Chapter 7 Vagrantfile - python requirements installation failing

I have everything running up until it attempts to install the python requirements via pip on [web], then it craps out. Any ideas on this? I tried logging into the vagrant vm and running the '/usr/bin/pip2' command, and I'm getting the same failure. Here's the output:

TASK [mezzanine : install Python requirements globally via pip] ****************
[DEPRECATION WARNING]: Invoking "pip" only once while using a loop via
squash_actions is deprecated. Instead of using a loop to supply multiple items
and specifying name: "{{ item }}", please use name: ['pip', 'virtualenv', 'virtualenvwrapper'] and remove the loop. This feature will be removed in
version 2.11. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
failed: [web] (item=['pip', 'virtualenv', 'virtualenvwrapper']) => {
"ansible_loop_var": "item",
"changed": false,
"cmd": [
"/usr/bin/pip2",
"install",
"-U",
"pip",
"virtualenv",
"virtualenvwrapper"
],
"item": [
"pip",
"virtualenv",
"virtualenvwrapper"
]
}

MSG:

stdout: Downloading/unpacking pip from https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl#sha256=b27c4dedae8c41aa59108f2fa38bf78e0890e590545bc8ece7cdceb4ba60f6e4
Downloading/unpacking virtualenv from https://files.pythonhosted.org/packages/45/24/27197e06ff269e54a05fcb7e270d5648fafe076eafd4ec289859a3dc4905/virtualenv-20.0.27-py2.py3-none-any.whl#sha256=c51f1ba727d1614ce8fd62457748b469fbedfdab2c7e5dd480c9ae3fbe1233f1
Downloading/unpacking virtualenvwrapper
Running setup.py (path:/tmp/pip_build_root/virtualenvwrapper/setup.py) egg_info for package virtualenvwrapper
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)

Installed /tmp/pip_build_root/virtualenvwrapper/pbr-5.4.5-py2.7.egg
[pbr] Processing SOURCES.txt
warning: LocalManifestMaker: standard file '-c' not found

warning: no previously-included files found matching '.gitignore'
warning: no previously-included files found matching '.gitreview'
warning: no previously-included files matching '*.pyc' found anywhere in distribution

Downloading/unpacking appdirs>=1.4.3,<2 (from virtualenv)
Downloading appdirs-1.4.4-py2.py3-none-any.whl
Downloading/unpacking distlib>=0.3.1,<1 (from virtualenv)
Downloading/unpacking pathlib2>=2.3.3,<3 (from virtualenv)
Downloading pathlib2-2.3.5-py2.py3-none-any.whl
Downloading/unpacking filelock>=3.0.0,<4 (from virtualenv)
Downloading filelock-3.0.12.tar.gz
Running setup.py (path:/tmp/pip_build_root/filelock/setup.py) egg_info for package filelock
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)

Downloading/unpacking six>=1.9.0,<2 (from virtualenv)
Downloading six-1.15.0-py2.py3-none-any.whl
Downloading/unpacking importlib-metadata>=0.12,<2 (from virtualenv)
Downloading importlib_metadata-1.7.0-py2.py3-none-any.whl
Downloading/unpacking importlib-resources>=1.0 (from virtualenv)
Downloading importlib_resources-3.0.0-py2.py3-none-any.whl
Downloading/unpacking virtualenv-clone (from virtualenvwrapper)
Downloading virtualenv_clone-0.5.4-py2.py3-none-any.whl
Downloading/unpacking stevedore (from virtualenvwrapper)
Running setup.py (path:/tmp/pip_build_root/stevedore/setup.py) egg_info for package stevedore
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)

Installed /tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg
Marker evaluation failed, see the following error.  For more information see: http://docs.openstack.org/pbr/latest/user/using.html#environment-markers
ERROR:root:Error parsing
Traceback (most recent call last):
  File "/tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg/pbr/core.py", line 96, in pbr
    attrs = util.cfg_to_args(path, dist.script_args)
  File "/tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg/pbr/util.py", line 273, in cfg_to_args
    kwargs = setup_cfg_to_setup_kwargs(config, script_args)
  File "/tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg/pbr/util.py", line 472, in setup_cfg_to_setup_kwargs
    if pkg_resources.evaluate_marker('(%s)' % env_marker):
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1271, in evaluate_marker
    return cls.interpret(parser.expr(text).totuple(1)[1])
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1306, in interpret
    return op(nodelist)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1223, in atom
    return cls.interpret(nodelist[2])
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1306, in interpret
    return op(nodelist)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1241, in comparison
    raise SyntaxError(repr(cop)+" operator not allowed in environment markers")
SyntaxError: '<' operator not allowed in environment markers
error in setup command: Error parsing /tmp/pip_build_root/stevedore/setup.cfg: SyntaxError: '<' operator not allowed in environment markers
Complete output from command python setup.py egg_info:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'

warnings.warn(msg)

/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'

warnings.warn(msg)

Installed /tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg

Marker evaluation failed, see the following error. For more information see: http://docs.openstack.org/pbr/latest/user/using.html#environment-markers

ERROR:root:Error parsing

Traceback (most recent call last):

File "/tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg/pbr/core.py", line 96, in pbr

attrs = util.cfg_to_args(path, dist.script_args)

File "/tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg/pbr/util.py", line 273, in cfg_to_args

kwargs = setup_cfg_to_setup_kwargs(config, script_args)

File "/tmp/pip_build_root/stevedore/pbr-5.4.5-py2.7.egg/pbr/util.py", line 472, in setup_cfg_to_setup_kwargs

if pkg_resources.evaluate_marker('(%s)' % env_marker):

File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1271, in evaluate_marker

return cls.interpret(parser.expr(text).totuple(1)[1])

File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1306, in interpret

return op(nodelist)

File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1223, in atom

return cls.interpret(nodelist[2])

File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1306, in interpret

return op(nodelist)

File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1241, in comparison

raise SyntaxError(repr(cop)+" operator not allowed in environment markers")

SyntaxError: '<' operator not allowed in environment markers

error in setup command: Error parsing /tmp/pip_build_root/stevedore/setup.cfg: SyntaxError: '<' operator not allowed in environment markers


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/stevedore
Storing debug log for failure in /root/.pip/pip.log

PLAY RECAP *********************************************************************
db : ok=7 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
web : ok=4 changed=1 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Chapter 6 ssh-add / github public key issues

https://stackoverflow.com/questions/20952689/ansible-ssh-forwarding-doesnt-seem-to-work-with-vagrant has some useful answers when trying to work out why git clone doesn't work (ie public key issues).

Personally i had multiple ssh key pairs of various types, and when using a catch-all ssh-add, this added keys which weren't known to github.

I specified the public key to add to the agent, and had to remove known_hosts entries for the vagrant host which used the wrong public_key.

ch06. ImportError: cannot import name 're_path' from 'django.urls'

Running the current version of ch06 playbook as described in the README(creating the secrets.yml and then starting vagrant up) does not result in the desired configuration.
A fatal error prevents further progress on the "Initialize the database" task.
It seems to be caused by a package dependency misconfiguration.

ImportError: cannot import name 're_path' from 'django.urls' (/home/vagrant/.virtualenvs/mezzanine_example/lib/python3.8/site-packages/django/urls/init.py)

The indicated path does contain the django.urls module, but does not appear to have re_path declared therein.
re_path has been introduced in Django 2.
This would seemingly indicate the project attempts to use a Django method only available in versions past 2.
"./manage.py --version" command has been executed in the project directory on the remote host to determine the Django version installed.

"out": "1.11.29"

I've tried adding Django>=2 to the requirements.txt to explicitly request a minimal compatible version of Django, but this version of Mezzanine requires Django<=1.18.

Confused, I've tried simply going for the freshest version of Mezzanine found on pypi.org, Mezzanine 5.1.3 (Django has also been removed from requirements.txt)
This approach didn't work, as well. It resulted in a similar looking error concerning another Django method that has been made deprecated and removed in Django 3.

ImportError: cannot import name ‘ugettext_lazy’ from ‘django.utils.translation’

Finally, I've tried sticking with the most recent Mezzanine release and adding Django>=2,<3 to the requirements.
This got me through without ImportErrors, only to end in errors of a different kind on the same task:

SystemCheckError: System check identified some issues:
ERRORS:
?: (admin.E406) 'django.contrib.messages' must be in INSTALLED_APPS in order to use the admin application.
?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application.
?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' must be in MIDDLEWARE in order to use the admin application.
?: (admin.E410) 'django.contrib.sessions.middleware.SessionMiddleware' must be in MIDDLEWARE in order to use the admin application.
WARNINGS:
?: (mezzanine.core.W04) mezzanine.core.middleware.SitePermissionMiddleware missing from settings.MIDDLEWARE - per site permissions not applied
?: (mezzanine.core.W05) You have included 'mezzanine.template.loader_tags' as a builtin in your template configuration. 'loader_tags' no longer exists and should be removed.
If you're still using the {% overextends %} tag please replace it with Django's {% extend %} for identical results.\n",
"path": "/home/vagrant/.virtualenvs/mezzanine_example/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
"syspath": ["/tmp/ansible_django_manage_payload_2g_c3i7u/ansible_django_manage_payload.zip", "/usr/lib/python38.zip", "/usr/lib/python3.8", "/usr/lib/python3.8/lib-dynload", "/usr/local/lib/python3.8/dist-packages", "/usr/lib/python3/dist-packages"]}

At this point I doubt I have the understanding necessary to resolve this issue.
Not sure if the reason for the original issue has been identified correctly.

Original error's full callback stack is attached:
ch06_Intitialize_the_database_ImportError.txt

Chapter 10 - Error handling with Blocks

Victor wrote in the online errata:

The example at 10-29 and 10-30 differs but also it says that the objective is ¨If all we want to do is get upgraded VMs back to the load-balancer cluster, the play will look a bit different". Accordingly to Ansible documentation, this is not true since:

"If an error occurs in the block and the rescue task succeeds, Ansible reverts the failed status of the original task for the run and continues to run the play as if the original task had succeeded." meaning that the snapshot is reverted and the hosts with a failed upgrade are added back to the load balancer with the previous version of the application.

3E: ch01 Vagrantfile

Vagrant is currently configured to create VirtualBox synced folders with
the SharedFoldersEnableSymlinksCreate option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false

Examples are incomplete and hard to find

Lets say I would like to copy and try Example 2-6.
How would I do this ?
Amazon Cloud-Reader would not let me copy it and this repo does not contain it.
Makes reading the book much harder than it should be :- (

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.