Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 4 additions & 36 deletions docs/operations/chameleon-tools/image-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,14 @@ By default, the automatic deployment task is _disabled_. To enable the task, set
systemctl list-timers 'image_deploy'
```

You can also deploy the images manually by running the following commands:
You can also deploy the images manually by running the following command:

```shell
# to deploy a specific image
docker run --rm --net=host -v "/etc/chameleon_image_tools/site.yaml:/etc/chameleon_image_tools/site.yaml" \
docker.chameleoncloud.org/chameleon_image_tools:latest deploy \
--site-yaml /etc/chameleon_image_tools/site.yaml \
--image <image_id>

# to deploy by image properties
docker run --rm --net=host -v "/etc/chameleon_image_tools/site.yaml:/etc/chameleon_image_tools/site.yaml" \
docker.chameleoncloud.org/chameleon_image_tools:latest deploy \
--site-yaml /etc/chameleon_image_tools/site.yaml \
--latest <distro>,<release>,<variant>
```

### Cleaner

To avoid accumulation of the older version and deprecated Chameleon-supported images in your site, we implement an image cleaning tool that cleans up images. The tool will:

* Check and skip the images that are currently used by any instance.
* Hide images that are 12 months or older (i.e. set visibility of the images to `private`). You can also tune this number by overwriting `hide_image_age_in_month` in the site `defaults.yml`.
* Delete images that are 18 months or older. You can also tune this number by overwriting `delete_image_age_in_month` in the site `defaults.yml`.

By default, the automatic cleaning task is _disabled_. To enable the task, set `enable_image_cleaner: yes` in the site `defaults.yml`. Then, run the `post-deploy` or run the `chameleon_image_tools` playbook. The automatic cleaning task runs daily to hide or delete the older version and deprecated Chameleon-supported images. You can check the installed automatic cleaning task via the systemd [timers](https://wiki.archlinux.org/index.php/Systemd/Timers).

```shell
systemctl list-timers 'image_clean'
docker run --rm --net=host -v "/etc/hammers:/etc/hammers:ro" \
ghcr.io/chameleoncloud/chameleon_site_tools:sha-583d81d \
image_deployer --site /etc/hammers/site.yaml --dry-run
```

You can also clean the images manually by running the following command:

```shell
docker run --rm --net=host -v "/etc/chameleon_image_tools/site.yaml:/etc/chameleon_image_tools/site.yaml" \
docker.chameleoncloud.org/chameleon_image_tools:latest clean \
--site-yaml /etc/chameleon_image_tools/site.yaml
```

To perform a dry-run, add `--dry-run` flag to the above command to only print without actual hiding and deleting.

### IPA Image Tester
Ironic Python Agent (IPA) is an agent for controlling and deploying Ironic controlled baremetal nodes. In order to support various hardware types, Chameleon builds and deploys
custom IPA images based on OpenStack upstream releases. To deploy Chameleon IPA images to site Glance, please use the [deployer tool](#deployer).
Expand Down
5 changes: 5 additions & 0 deletions kolla/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ enable_usage_reporting: no
# image tools
enable_image_deployer: no
enable_image_cleaner: no
image_container: chameleon-supported-images
image_type: qcow2
image_prefix: testing_
image_scope: prod
image_object_store_url: https://chi.tacc.chameleoncloud.org:7480/swift/v1/AUTH_key

# Manila
default_share_type: cephfsnfstype
7 changes: 2 additions & 5 deletions roles/chameleon_image_tools/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
---
chameleon_image_tools_docker_image: ghcr.io/chameleoncloud/chameleon_image_tools:latest
chameleon_image_tools_config_dir: /etc/chameleon_image_tools

hide_image_age_in_month: 12
delete_image_age_in_month: 18
chameleon_image_tools_docker_image: ghcr.io/chameleoncloud/chameleon_site_tools:sha-384af41
chameleon_image_tools_config_dir: /etc/hammers
104 changes: 74 additions & 30 deletions roles/chameleon_image_tools/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,58 @@
name: "{{ chameleon_image_tools_docker_image }}"
force_source: yes

# Cleanup old service, scripts, and timer (if present)
- name: Cleanup old image_deploy timer (stop & disable)
become: yes
systemd:
name: image_deploy.timer
state: stopped
enabled: no
ignore_errors: yes
when: enable_image_deployer | bool

- name: Cleanup old image_deploy service (stop & disable)
become: yes
systemd:
name: image_deploy.service
state: stopped
enabled: no
ignore_errors: yes
when: enable_image_deployer | bool

- name: Remove old timer unit file
become: yes
file:
path: /etc/systemd/system/image_deploy.timer
state: absent
ignore_errors: yes
when: enable_image_deployer | bool

- name: Remove old service unit file
become: yes
file:
path: /etc/systemd/system/image_deploy.service
state: absent
ignore_errors: yes
when: enable_image_deployer | bool

- name: Remove old chameleon_image_tools config dir
become: yes
file:
path: /etc/chameleon_image_tools
state: absent
ignore_errors: yes
when: enable_image_deployer | bool

- name: Remove old wrapper script
become: yes
file:
path: /usr/local/sbin/chameleon-image-deploy
state: absent
ignore_errors: yes
when: enable_image_deployer | bool

# Setup new chameleon-image-deploy
- name: Create config directory
become: yes
file:
Expand All @@ -18,40 +70,32 @@
src: site.yaml.j2
dest: "{{ chameleon_image_tools_config_dir }}/site.yaml"

- name: Configure chameleon image deployer docker bash wrapper
- name: Deploy chameleon-image-deploy systemd service
become: yes
template:
src: chameleon-image-deploy.j2
mode: 0700
dest: /usr/local/sbin/chameleon-image-deploy
src: chameleon-image-deploy.service.j2
dest: /etc/systemd/system/chameleon-image-deploy.service
mode: '0644'
when: enable_image_deployer | bool

- name: Set up image deployer periodic task
include_role:
name: chameleon.periodic_task
apply:
become: yes
vars:
task_name: "image_deploy"
task_command: "/usr/local/sbin/chameleon-image-deploy"
task_calendar: "daily"
- name: Deploy chameleon-image-deploy timer unit
become: yes
template:
src: chameleon-image-deploy.timer.j2
dest: /etc/systemd/system/chameleon-image-deploy.timer
mode: '0644'
when: enable_image_deployer | bool

- name: Configure chameleon image cleaner docker bash wrapper
- name: Reload systemd to pick up new/changed units
become: yes
template:
src: chameleon-image-clean.j2
mode: 0700
dest: /usr/local/sbin/chameleon-image-clean
when: enable_image_cleaner | bool

- name: Set up image cleaner periodic task
include_role:
name: chameleon.periodic_task
apply:
become: yes
vars:
task_name: "image_clean"
task_command: "/usr/local/sbin/chameleon-image-clean"
task_calendar: "daily"
when: enable_image_cleaner | bool
systemd:
daemon_reload: yes
when: enable_image_deployer | bool

- name: Enable & start chameleon-image-deploy.timer
become: yes
systemd:
name: chameleon-image-deploy.timer
enabled: yes
state: started
when: enable_image_deployer | bool

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Chameleon Image Deployer
After=docker.service
Requires=docker.service

[Service]
Type=oneshot
ExecStart=/usr/bin/docker run --rm --net=host \
-v "{{ chameleon_image_tools_config_dir }}:{{ chameleon_image_tools_config_dir }}:ro" \
{{ chameleon_image_tools_docker_image }} \
image_deployer --site {{ chameleon_image_tools_config_dir }}/site.yaml

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Run Chameleon Image Deployer daily

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target
9 changes: 6 additions & 3 deletions roles/chameleon_image_tools/templates/site.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ admin_username: {{ keystone_admin_username }}
admin_password: {{ keystone_admin_password }}
admin_project: {{ keystone_admin_project_name }}
region_name: {{ openstack_region_name }}

hide_image_age_in_month: {{ hide_image_age_in_month }}
delete_image_age_in_month: {{ delete_image_age_in_month }}
image_container: {{ image_container }}
image_type: {{ image_type }}
image_prefix: {{ image_prefix }}
scope: {{ image_scope }}
image_store_cloud: {{ openstack_region_name }}
object_store_url: {{ image_object_store_url }}
Loading