[libvirt] [jenkins-ci PATCH 0/3] guests: Configure ccache

See patch 3/3 for the rationale. Andrea Bolognani (3): guests: Rename 'ci' flavor to 'jenkins' guests: Factor out user creation guests: Configure ccache guests/README.markdown | 9 +++++---- guests/files/ccache.conf | 1 + guests/lcitool | 12 ++++++------ guests/site.yml | 8 ++------ guests/tasks/jenkins.yml | 6 ------ guests/tasks/test.yml | 21 --------------------- guests/tasks/user.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 56 insertions(+), 43 deletions(-) create mode 100644 guests/files/ccache.conf delete mode 100644 guests/tasks/test.yml create mode 100644 guests/tasks/user.yml -- 2.14.3

Having the name of the user that can access the machine match the name of the flavor, as is already the case for the 'test' flavor, makes some things easier. We can change this safely because the CentOS CI is the only user of the 'ci' flavor, and we can easily coordinate a configuration change to avoid breakages. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/README.markdown | 9 +++++---- guests/lcitool | 12 ++++++------ guests/site.yml | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/guests/README.markdown b/guests/README.markdown index fa1e8a5..bc780f3 100644 --- a/guests/README.markdown +++ b/guests/README.markdown @@ -79,11 +79,12 @@ single time you want to connect. Just add to your `~/.ssh/config` file to achieve all of the above. -CI use ------- +Jenkins CI use +-------------- -You'll need to configure `lcitool` to use the `ci` flavor for guests: -to do so, just write `ci` in the `~/.config/lcitool/flavor` file. +You'll need to configure `lcitool` to use the `jenkins` flavor for +guests: to do so, just write `jenkins` in the `~/.config/lcitool/flavor` +file. Once a guest has been prepared, you'll be able to log in as root either via SSH (your public key will have been authorized) or on the serial diff --git a/guests/lcitool b/guests/lcitool index ccd0a59..5b2efb9 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -67,20 +67,20 @@ load_config() { VAULT_PASS_FILE="$CONFIG_DIR/vault-password" ROOT_PASS_FILE="$CONFIG_DIR/root-password" - # Two flavors are supported: test (default) and ci. Read the + # Two flavors are supported: test (default) and jenkins. Read the # flavor from configuration, validate it and write it back in case # it was not present FLAVOR="$(cat "$FLAVOR_FILE" 2>/dev/null)" FLAVOR=${FLAVOR:-test} - test "$FLAVOR" = test || test "$FLAVOR" = ci || { + test "$FLAVOR" = test || test "$FLAVOR" = jenkins || { die "$PROGRAM_NAME: Invalid flavor '$FLAVOR'" } echo "$FLAVOR" >"$FLAVOR_FILE" || { die "$PROGRAM_NAME: $FLAVOR_FILE: Unable to save flavor" } - test "$FLAVOR" = ci && { - # The vault password is only needed for the ci flavor, so only + test "$FLAVOR" = jenkins && { + # The vault password is only needed for the jenkins flavor, so only # validate it in that case test -f "$VAULT_PASS_FILE" && test "$(cat "$VAULT_PASS_FILE")" || { die "$PROGRAM_NAME: $VAULT_PASS_FILE: Missing or invalid password" @@ -160,8 +160,8 @@ do_install() *kickstart*|*ks*) EXTRA_ARGS="ks=file:/${INSTALL_CONFIG##*/}" ;; esac - # Only configure autostart for the guest for the ci flavor - test "$FLAVOR" = ci && { + # Only configure autostart for the guest for the jenkins flavor + test "$FLAVOR" = jenkins && { AUTOSTART="--autostart" } diff --git a/guests/site.yml b/guests/site.yml index 5df18e6..cb4ec0e 100644 --- a/guests/site.yml +++ b/guests/site.yml @@ -30,7 +30,7 @@ # Configure the Jenkins agent - include: tasks/jenkins.yml when: - - flavor == 'ci' + - flavor == 'jenkins' - projects is defined # jenkins is a pseudo-project - ( 'jenkins' in projects ) -- 2.14.3

On Mon, Mar 19, 2018 at 04:29:55PM +0100, Andrea Bolognani wrote:
Having the name of the user that can access the machine match the name of the flavor, as is already the case for the 'test' flavor, makes some things easier.
We can change this safely because the CentOS CI is the only user of the 'ci' flavor, and we can easily coordinate a configuration change to avoid breakages.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/README.markdown | 9 +++++---- guests/lcitool | 12 ++++++------ guests/site.yml | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Some steps involved in creating the user account are the same regardless of flavor, and more common steps will be introduced later on, so it makes sense to have them all in the same place instead of duplicating them. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/site.yml | 6 +----- guests/tasks/jenkins.yml | 6 ------ guests/tasks/test.yml | 21 --------------------- guests/tasks/user.yml | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 guests/tasks/test.yml create mode 100644 guests/tasks/user.yml diff --git a/guests/site.yml b/guests/site.yml index cb4ec0e..5f69cfd 100644 --- a/guests/site.yml +++ b/guests/site.yml @@ -17,6 +17,7 @@ # Prepare the base environment - include: tasks/base.yml - include: tasks/compat.yml + - include: tasks/user.yml # Install build dependencies for each project - include: tasks/packages.yml @@ -34,8 +35,3 @@ - projects is defined # jenkins is a pseudo-project - ( 'jenkins' in projects ) - - # Configure the test environment - - include: tasks/test.yml - when: - - flavor == 'test' diff --git a/guests/tasks/jenkins.yml b/guests/tasks/jenkins.yml index 9bb150b..94c2404 100644 --- a/guests/tasks/jenkins.yml +++ b/guests/tasks/jenkins.yml @@ -7,12 +7,6 @@ set_fact: jenkins_secret: '{{ vault.jenkins_secrets[inventory_hostname] }}' -- name: Create Jenkins user account - user: - name: jenkins - comment: Jenkins - password: '*' - - name: Download Jenkins agent get_url: url: https://ci.centos.org/jnlpJars/slave.jar diff --git a/guests/tasks/test.yml b/guests/tasks/test.yml deleted file mode 100644 index 10146b9..0000000 --- a/guests/tasks/test.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Create test user account - user: - name: test - comment: test - password: $6$xSlfvkcsDgPmRAMX$mFh9qRmFFW9cyW1n5/jeHvq4OmJA8WzSD70Mfis3VHc3Z5imZeiQAg9VNL4sFEtmDy/siU3nJL.QeAapCgfL20 - shell: '{{ bash }}' - -- name: Configure ssh access for the test user - authorized_key: - user: test - key: '{{ lookup("file", lookup("env", "HOME") + "/.ssh/id_rsa.pub") }}' - state: present - -- name: Grant passwordless sudo access to the test user - lineinfile: - path: '{{ sudoers }}' - line: 'test ALL=(ALL) NOPASSWD: ALL' - state: present - backup: yes - validate: 'visudo -cf %s' diff --git a/guests/tasks/user.yml b/guests/tasks/user.yml new file mode 100644 index 0000000..781c3d4 --- /dev/null +++ b/guests/tasks/user.yml @@ -0,0 +1,32 @@ +--- +- name: '{{ flavor }}: Create user account' + user: + name: '{{ flavor }}' + comment: '{{ flavor }}' + password: '*' + shell: '{{ bash }}' + +- name: '{{ flavor }}: Set password' + user: + name: '{{ flavor }}' + password: '$6$xSlfvkcsDgPmRAMX$mFh9qRmFFW9cyW1n5/jeHvq4OmJA8WzSD70Mfis3VHc3Z5imZeiQAg9VNL4sFEtmDy/siU3nJL.QeAapCgfL20' + when: + - flavor == 'test' + +- name: '{{ flavor }}: Configure ssh access' + authorized_key: + user: '{{ flavor }}' + key: '{{ lookup("file", lookup("env", "HOME") + "/.ssh/id_rsa.pub") }}' + state: present + when: + - flavor == 'test' + +- name: '{{ flavor }}: Grant passwordless sudo access' + lineinfile: + path: '{{ sudoers }}' + line: '{{ flavor }} ALL=(ALL) NOPASSWD: ALL' + state: present + backup: yes + validate: 'visudo -cf %s' + when: + - flavor == 'test' -- 2.14.3

On Mon, Mar 19, 2018 at 04:29:56PM +0100, Andrea Bolognani wrote:
Some steps involved in creating the user account are the same regardless of flavor, and more common steps will be introduced later on, so it makes sense to have them all in the same place instead of duplicating them.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/site.yml | 6 +----- guests/tasks/jenkins.yml | 6 ------ guests/tasks/test.yml | 21 --------------------- guests/tasks/user.yml | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 guests/tasks/test.yml create mode 100644 guests/tasks/user.yml
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Disk size for guests is somewhat limited, so we need to tell ccache to only consume a reasonable chunk of it. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/files/ccache.conf | 1 + guests/tasks/user.yml | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 guests/files/ccache.conf diff --git a/guests/files/ccache.conf b/guests/files/ccache.conf new file mode 100644 index 0000000..48c3756 --- /dev/null +++ b/guests/files/ccache.conf @@ -0,0 +1 @@ +max_size = 2G diff --git a/guests/tasks/user.yml b/guests/tasks/user.yml index 781c3d4..3db5258 100644 --- a/guests/tasks/user.yml +++ b/guests/tasks/user.yml @@ -30,3 +30,13 @@ validate: 'visudo -cf %s' when: - flavor == 'test' + +- name: '{{ flavor }}: Configure ccache' + file: + path: /home/{{ flavor }}/.ccache + state: directory + +- name: '{{ flavor }}: Configure ccache' + copy: + src: files/ccache.conf + dest: /home/{{ flavor }}/.ccache/ccache.conf -- 2.14.3

On Mon, Mar 19, 2018 at 04:29:57PM +0100, Andrea Bolognani wrote:
Disk size for guests is somewhat limited, so we need to tell ccache to only consume a reasonable chunk of it.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/files/ccache.conf | 1 + guests/tasks/user.yml | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 guests/files/ccache.conf
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
diff --git a/guests/files/ccache.conf b/guests/files/ccache.conf new file mode 100644 index 0000000..48c3756 --- /dev/null +++ b/guests/files/ccache.conf @@ -0,0 +1 @@ +max_size = 2G
This matches what i've already set manually on the rawhide vm to solve the out of space error. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Andrea Bolognani
-
Daniel P. Berrangé