ansible tripleo修改image-ansible角色以允许修改为tripleo项目构建的容器图像。
ansible-role-tripleo-modify-image的Python项目详细描述
Tripleo修改图像
允许修改为Tripleo项目生成的容器图像的角色。
角色变量
list table::用于修改图像的变量 :宽度:自动 :标题行:1
- 姓名
- 默认值
- 说明
source_image
[undefined]
- 对要修改的源映像的强制完全限定引用。将复制和修改提供的dockerfile,使from指令与此变量匹配。
modify_dir_path
[undefined]
- 包含要修改图像的dockerfile的目录的强制路径
modified_append_tag
date +-modified-%Y%m%d%H%M%S
- 要附加在标记之后的字符串,以指示这是源图像的修改版本。
target_image
[undefined]
- 如果设置了,修改后的图像将被标记为
target_image + modified_append_tag
。如果未设置target_image
,则修改后的图像将被标记为source_image + modified_append_tag
。如果图像的目的没有改变,那么依赖source_image + modified_append_tag
标记就足以确定这是源图像的修改版本。
container_build_tool
docker
- 用于构建容器的工具,可以是“docker”或“buildah”
list table::用于百胜更新的变量 :宽度:自动 :标题行:1
- 姓名
- 默认值
- 说明
source_image
[undefined]
- 请参见修改图像变量
modified_append_tag
date +-modified-%Y%m%d%H%M%S
- 请参见修改图像变量
target_image
''
- 请参见修改图像变量
update_repo
''
- 如果已设置,则将更新此repo中的包。其他回购协议将仅用于这些更新的依赖项。
yum_repos_dir_path
None
- 更新期间用作
/etc/yum.repos.d
的目录的可选路径
container_build_tool
docker
- 请参见修改图像变量
list table::用于dev安装的变量 :宽度:自动 :标题行:1
- 姓名
- 默认值
- 说明
source_image
[undefined]
- 请参见修改图像变量
modified_append_tag
date +-modified-%Y%m%d%H%M%S
- 请参见修改图像变量
target_image
''
- 请参见修改图像变量
container_build_tool
docker
- 请参见修改图像变量
refspecs
[]
- 将安装到生成的容器中的项目/refspec对的数组。目前只支持python源项目。
python_dir
[]
- 目录,该目录包含准备用pip安装的python项目。
要求
- ansible=2.4
- python=2.6
- docker py>;=1.7.0
- Docker API=1.20
依赖关系
无
手册示例
修改图像
The following playbook will produce a modified image with the tag
`:latest-modified-<timestamp>` based on the Dockerfile in the custom directory
`/path/to/example_modify_dir`.
.. code-block::
- hosts: localhost
tasks:
- name: include tripleo-modify-image
import_role:
name: tripleo-modify-image
tasks_from: modify_image.yml
vars:
source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
modify_dir_path: /path/to/example_modify_dir
container_build_tool: docker # or buildah
The directory `example_modify_dir` contains the `Dockerfile` which will perform
the modification, for example:
.. code-block::
# This will be replaced in the file Dockerfile.modified
FROM centos-binary-nova-api
# switch to root to install packages
USER root
# install packages
RUN curl "https://bootstrap.pypa.io/get-pip.py" -o "/tmp/get-pip.py"
RUN python /tmp/get-pip.py
# switch the container back to the default user
USER nova
Yum update
~~~~~~~~~~
The following playbook will produce a modified image with the tag
`:latest-updated` which will do a yum update using the host's /etc/yum.repos.d.
The yum update will only occur if there are differences between host and image
package versions. In this playbook the tasks\_from is set as a variable instead
of an `import_role` parameter.
.. code-block::
- hosts: localhost
tasks:
- name: include tripleo-modify-image
import_role:
name: tripleo-modify-image
vars:
tasks_from: yum_update.yml
source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
compare_host_packages: true
yum_repos_dir_path: /etc/yum.repos.d
modified_append_tag: updated
container_build_tool: docker # or buildah
RPM install
~~~~~~~~~~~
The following playbook will produce a modified image with RPMs from the
specified rpms\_path on the local filesystem installed as a new layer
for the container. The new container tag is appened with the '-hotfix'
suffix. Useful for creating adhoc hotfix containers with local RPMs with no
network connectivity.
.. code-block::
- hosts: localhost
tasks:
- name: include tripleo-modify-image
import_role:
name: tripleo-modify-image
vars:
tasks_from: rpm_install.yml
source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
rpms_path: /foo/bar
modified_append_tag: -hotfix
Dev install
~~~~~~~~~~~
The following playbook will produce a modified image with Python source
code installed via pip. To minimize dependencies within the container
we generate the sdist locally and then copy it into the resulting
container image as an sdist tarball to run pip install locally.
It can be used to pull a review from OpenDev Gerrit:
.. code-block::
- hosts: localhost
connection: local
tasks:
- name: dev install heat-api
import_role:
name: tripleo-modify-image
vars:
tasks_from: dev_install.yml
source_image: docker.io/tripleomaster/centos-binary-heat-api:current-tripleo
refspecs:
-
project: heat
refspec: refs/changes/12/1234/3
modified_append_tag: -devel
or it can be used to build an image from a local Python directory:
.. code-block::
- hosts: localhost
connection: local
tasks:
- name: dev install heat-api
import_role:
name: tripleo-modify-image
vars:
tasks_from: dev_install.yml
source_image: docker.io/tripleomaster/centos-binary-heat-api:current-tripleo
modified_append_tag: -devel
python_dir:
- /home/joe/git/openstack/heat
License
-------
Apache 2.0