Skip to content

Commit

Permalink
Merge pull request #3 from ktooi/add_conf_crio_tasks
Browse files Browse the repository at this point in the history
Add conf crio tasks
  • Loading branch information
ktooi authored Nov 23, 2022
2 parents 7d8d75f + 94d1e93 commit afd685a
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 7 deletions.
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ This role will do the following.
* Load Kernel module.
* Configure Kernel parameters.
* Install CRI-O.

This role does not do the following

* Configure CRI-O.

## Requirements
Expand Down Expand Up @@ -85,6 +82,41 @@ The format is similar to `crio_version_url`, but with or without `/`.

It is automatically set from the value of `crio_version`, so you don't need to specify it.

```yaml
crio_conf: {}
```

This parameter specifies the contents of crio.conf.
See https://github.com/cri-o/cri-o/blob/main/docs/crio.conf.5.md for parameters that can be specified in crio.conf.

`crio_conf` can be specified as follows:

```yaml
crio_conf:
"table":
option: value
"table.subtable1":
option: value
"table.subtable2":
option: value
```

In this case, crio.conf outputs the following:

```
[table]
option = value
[table.subtable1]
option = value
[table.subtable2]
option = value
```

See [crio_conf.yml.example](./defaults/crio_conf.yml.example) for a more realistic specificatioin.

## Dependencies

None.
Expand Down
38 changes: 35 additions & 3 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ RHEL/CentOS, Debian/Ubuntu サーバに CRI-O をインストールします。
* Kernel module のロード。
* Kernel parameter の設定。
* CRI-O をインストール。

この role では次のことを行いません。

* CRI-O の設定。

## Requirements
Expand Down Expand Up @@ -84,6 +81,41 @@ CRI-O のバージョンを長い形式で指定するパラメータです。

`crio_version` の値から自動的に設定されるので指定する必要はありません。

```yaml
crio_conf: {}
```

crio.conf の内容を指定するパラメータです。
crio.conf に指定可能なパラメータは https://github.com/cri-o/cri-o/blob/main/docs/crio.conf.5.md を参照してください。

`crio_conf` は次のように指定可能です。

```yaml
crio_conf:
"table":
option: value
"table.subtable1":
option: value
"table.subtable2":
option: value
```

この場合、 crio.conf は次のように出力されます。

```
[table]
option = value

[table.subtable1]
option = value

[table.subtable2]
option = value

```
より実例に近い指定については、 [crio_conf.yml.example](./defaults/crio_conf.yml.example) を参照してください。
## Dependencies
None.
Expand Down
44 changes: 44 additions & 0 deletions defaults/crio_conf.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
crio_conf:
"crio":
root: "/home/abuild/.local/share/containers/storage"
runroot: "/tmp/containers-user-399/containers"
storage_driver: vfs
storage_option: []
log_dir: "/var/log/crio/pods"
version_file: "/var/run/crio/version"
version_file_persist: "/var/lib/crio/version"
internal_wipe: true
clean_shutdown_file: "/var/lib/crio/clean.shutdown"
"crio.metrics":
enable_metrics: false
metrics_collectors:
- "operations"
- "operations_latency_microseconds_total"
- "operations_latency_microseconds"
- "operations_errors"
- "image_pulls_by_digest"
- "image_pulls_by_name"
- "image_pulls_by_name_skipped"
- "image_pulls_failures"
- "image_pulls_successes"
- "image_pulls_layer_size"
- "image_layer_reuse"
- "containers_oom_total"
- "containers_oom"
- "processes_defunct"
- "operations_total"
- "operations_latency_seconds"
- "operations_latency_seconds_total"
- "operations_errors_total"
- "image_pulls_bytes_total"
- "image_pulls_skipped_bytes_total"
- "image_pulls_failure_total"
- "image_pulls_success_total"
- "image_layer_reuse_total"
- "containers_oom_count_total"
metrics_port: 9090
metrics_socket: ""
metrics_cert: ""
metrics_key: ""

3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ crio_modules:
- br_netfilter
crio_modprobe_filename: "/etc/modules-load.d/crio-modules.conf"
# crio_runc_version:
crio_conf_file: "/etc/crio/crio.conf"
# See also crio_conf.yml.example for more information on configuring crio_conf.
# crio_conf: {}

# For Debian/Ubuntu
crio_apt_cache_valid_time: 86400
Expand Down
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Restart CRI-O
systemd:
name: crio
state: restarted
become: true
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies: []
galaxy_info:
role_name: crio
author: ktooi
description: Install cri-o for RHEL/CentOS and Debian/Ubuntu.
description: Install and configure cri-o for RHEL/CentOS and Debian/Ubuntu.
license: "license (MIT)"
min_ansible_version: 2.0
platforms:
Expand Down
12 changes: 12 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
---
- name: Generate crio.conf
template:
src: crio.conf.j2
dest: "{{ crio_conf_file }}"
owner: root
group: root
mode: "0644"
when: crio_conf is defined
# Skip the handler because CRI-O cannot be executed in the molecule environment.
notify: "{{ 'Restart CRI-O' if molecule_yml is not defined else omit }}"
become: true

- name: Ensure CRI-O is started and enabled at boot
systemd:
name: crio
Expand Down
24 changes: 24 additions & 0 deletions templates/crio.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% for section, options in crio_conf.items() %}
[{{ section }}]
{% for key, val in options.items() %}
{{ key }} =
{%- if val is string %}
"{{ val }}"
{% elif val is iterable and var is not mapping %}
[
{% for v in val %}
{% if v is string %}
"{{ v }}",
{% else %}
{{ v }},
{% endif %}
{% endfor %}
]
{% elif val is boolean %}
{{ val | string | lower }}
{% else %}
{{ val }}
{% endif %}
{% endfor %}

{% endfor %}

0 comments on commit afd685a

Please sign in to comment.