From 66fb3fa3420bf59aa8d922b26bf1503dfee2273d Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 19 Dec 2020 03:23:06 +0100 Subject: [PATCH 1/7] [#28] Verdaccio does not start. --- defaults/main.yml | 1 + meta/main.yml | 1 + tasks/main.yml | 109 +++++++++++++++++---------------- templates/verdaccio.service.j2 | 2 +- 4 files changed, 59 insertions(+), 54 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index f4b2846..6c15d81 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,5 @@ --- +verdaccio: /usr/bin/verdaccio verdaccio_version: '' verdaccio_configdir: '/home/verdaccio/verdaccio' verdaccio_datadir: '/home/verdaccio/verdaccio' diff --git a/meta/main.yml b/meta/main.yml index 61414d4..4c4afae 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -27,3 +27,4 @@ dependencies: - src: geerlingguy.nodejs version: 5.1.1 name: geerlingguy.nodejs + become: true diff --git a/tasks/main.yml b/tasks/main.yml index 07e2115..2d72277 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,23 +1,4 @@ --- -- name: verdaccio installed - npm: - name: verdaccio - version: "{{ verdaccio_version | default(omit) }}" - global: true - notify: restart verdaccio - -- name: verdaccio plugins installed - npm: - name: "{{ item.name }}" - version: "{{ item.version | default(omit) }}" - path: "{{ verdaccio_pluginsdir }}" - with_items: "{{ verdaccio_plugins }}" - when: verdaccio_plugins is not none - -- name: verdaccio user created - user: - name: verdaccio - - name: resolve npm config path command: npm config get prefix --no-update-notifier register: npm_config_prefix_resolve @@ -31,39 +12,61 @@ ("FAILED" not in npm_config_prefix_resolve.stderr) and (npm_config_prefix_resolve.stdout | length > 0) -- name: deploy verdaccio systemd unit - template: - src: verdaccio.service.j2 - dest: /etc/systemd/system/verdaccio.service - mode: 0600 - notify: systemd daemon-reload - -- name: verdaccio service enabled - systemd: - name: verdaccio - enabled: true - -- name: verdaccio directories creation - file: - path: "{{ item }}" - state: directory - owner: verdaccio - mode: 0755 - loop: - - "{{ verdaccio_datadir }}" - - "{{ verdaccio_configdir }}" +- block: + - name: verdaccio installed + npm: + name: verdaccio + version: "{{ verdaccio_version | default(omit) }}" + global: true + notify: restart verdaccio -- name: config deployed - template: - src: config.j2 - dest: "{{ verdaccio_configdir }}/verdaccio.yml" - owner: verdaccio - mode: 0600 - notify: restart verdaccio + - name: verdaccio user created + user: + name: verdaccio + + - name: deploy verdaccio systemd unit + template: + src: verdaccio.service.j2 + dest: /etc/systemd/system/verdaccio.service + mode: 0600 + notify: systemd daemon-reload + + - name: verdaccio service enabled + systemd: + name: verdaccio + enabled: true + state: started + + - name: verdaccio directories creation + file: + path: "{{ item }}" + state: directory + owner: verdaccio + mode: 0755 + loop: + - "{{ verdaccio_datadir }}" + - "{{ verdaccio_configdir }}" + + - name: config deployed + template: + src: config.j2 + dest: "{{ verdaccio_configdir }}/verdaccio.yml" + owner: verdaccio + mode: 0600 + notify: restart verdaccio + + - name: install logrotate script + template: + src: logrotate.j2 + dest: /etc/logrotate.d/verdaccio + owner: root + mode: 0644 + become: true -- name: install logrotate script - template: - src: logrotate.j2 - dest: /etc/logrotate.d/verdaccio - owner: root - mode: 0644 +- name: verdaccio plugins installed + npm: + name: "{{ item.name }}" + version: "{{ item.version | default(omit) }}" + path: "{{ verdaccio_pluginsdir }}" + with_items: "{{ verdaccio_plugins }}" + when: verdaccio_plugins is not none diff --git a/templates/verdaccio.service.j2 b/templates/verdaccio.service.j2 index 968552f..210c081 100644 --- a/templates/verdaccio.service.j2 +++ b/templates/verdaccio.service.j2 @@ -5,7 +5,7 @@ Description=verdaccio Service Type=simple User=verdaccio WorkingDirectory={{ verdaccio_datadir }} -ExecStart={{ npm_config_prefix }}/bin/verdaccio -c {{ verdaccio_configdir }}/verdaccio.yml +ExecStart={{ verdaccio }} -c {{ verdaccio_configdir }}/verdaccio.yml [Install] WantedBy=multi-user.target From 3c1f824bca00bce1ab23e2f5d746ea5af68c20cc Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 20 Dec 2020 15:27:56 +0100 Subject: [PATCH 2/7] [#28] Superfluous log rotate removed. --- defaults/main.yml | 15 +++--- molecule/default/playbook.yml | 1 + tasks/main.yml | 87 ++++++++++++++++------------------- templates/logrotate.j2 | 14 ------ 4 files changed, 49 insertions(+), 68 deletions(-) delete mode 100644 templates/logrotate.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 6c15d81..f2738ef 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,16 +1,17 @@ --- verdaccio: /usr/bin/verdaccio -verdaccio_version: '' -verdaccio_configdir: '/home/verdaccio/verdaccio' -verdaccio_datadir: '/home/verdaccio/verdaccio' -verdaccio_plugins: # Must be a list of name/version for the plugins +verdaccio_version: "" +verdaccio_configdir: "/home/verdaccio/verdaccio" +verdaccio_datadir: "/home/verdaccio/verdaccio" +verdaccio_plugins: # Must be a list of name/version for the plugins # For example: # - name: verdaccio-ldap # version: 4.2.0 # - name: verdaccio-groupnames # version: 1.0.4-1 verdaccio_pluginsdir: "{{verdaccio_datadir}}/plugins" -verdaccio_web_title: 'Verdaccio' +verdaccio_systemd_state: started +verdaccio_web_title: "Verdaccio" verdaccio_web_gravatar: false verdaccio_web_sort_packages: asc verdaccio_listen_address: 0.0.0.0 @@ -30,8 +31,8 @@ verdaccio_uplinks: verdaccio_packages: # Default packages using default parameters (bellow) - '@*/*': - '**': + "@*/*": + "**": # Example with custom parameters: # '@fortawesome/*': # proxy: diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml index 45cbc9f..9fc76cc 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -5,6 +5,7 @@ vars: nodejs_install_npm_user: root + verdaccio_systemd_state: stopped pre_tasks: - name: Update apt cache. diff --git a/tasks/main.yml b/tasks/main.yml index 2d72277..f6958bc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,54 +13,47 @@ (npm_config_prefix_resolve.stdout | length > 0) - block: - - name: verdaccio installed - npm: - name: verdaccio - version: "{{ verdaccio_version | default(omit) }}" - global: true - notify: restart verdaccio + - name: verdaccio installed + npm: + name: verdaccio + version: "{{ verdaccio_version | default(omit) }}" + global: true + notify: restart verdaccio - - name: verdaccio user created - user: - name: verdaccio - - - name: deploy verdaccio systemd unit - template: - src: verdaccio.service.j2 - dest: /etc/systemd/system/verdaccio.service - mode: 0600 - notify: systemd daemon-reload - - - name: verdaccio service enabled - systemd: - name: verdaccio - enabled: true - state: started - - - name: verdaccio directories creation - file: - path: "{{ item }}" - state: directory - owner: verdaccio - mode: 0755 - loop: - - "{{ verdaccio_datadir }}" - - "{{ verdaccio_configdir }}" - - - name: config deployed - template: - src: config.j2 - dest: "{{ verdaccio_configdir }}/verdaccio.yml" - owner: verdaccio - mode: 0600 - notify: restart verdaccio - - - name: install logrotate script - template: - src: logrotate.j2 - dest: /etc/logrotate.d/verdaccio - owner: root - mode: 0644 + - name: verdaccio user created + user: + name: verdaccio + + - name: deploy verdaccio systemd unit + template: + src: verdaccio.service.j2 + dest: /etc/systemd/system/verdaccio.service + mode: 0600 + notify: systemd daemon-reload + + - name: verdaccio service enabled + systemd: + name: verdaccio + enabled: true + state: started + + - name: verdaccio directories creation + file: + path: "{{ item }}" + state: directory + owner: verdaccio + mode: 0755 + loop: + - "{{ verdaccio_datadir }}" + - "{{ verdaccio_configdir }}" + + - name: config deployed + template: + src: config.j2 + dest: "{{ verdaccio_configdir }}/verdaccio.yml" + owner: verdaccio + mode: 0600 + notify: restart verdaccio become: true - name: verdaccio plugins installed diff --git a/templates/logrotate.j2 b/templates/logrotate.j2 deleted file mode 100644 index 28497f5..0000000 --- a/templates/logrotate.j2 +++ /dev/null @@ -1,14 +0,0 @@ -# {{ ansible_managed }} -{{ verdaccio_datadir }}/verdaccio.log { - weekly - rotate 8 - missingok - compress - copytruncate - sharedscripts - postrotate - /bin/kill -SIGUSR2 $(systemctl show --property MainPID --value verdaccio.service) - endscript -} - - From b4354188311a141b6f3e15af34de8d13104ab4e2 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 20 Dec 2020 16:18:38 +0100 Subject: [PATCH 3/7] [#28] Molecule updated. --- molecule/default/converge.yml | 7 +++++++ molecule/default/molecule.yml | 16 +++------------- molecule/default/playbook.yml | 16 ---------------- molecule/default/verify.yml | 10 ++++++++++ 4 files changed, 20 insertions(+), 29 deletions(-) create mode 100644 molecule/default/converge.yml delete mode 100644 molecule/default/playbook.yml create mode 100644 molecule/default/verify.yml diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..4e0ea2f --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + become: true + + roles: + - role: verdaccio.verdaccio diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 9fab1c2..4a9a940 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -6,20 +6,10 @@ driver: platforms: - name: instance image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" - command: ${MOLECULE_DOCKER_COMMAND:-""} - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: true pre_build_image: true provisioner: name: ansible - lint: - name: ansible-lint - playbooks: - converge: ${MOLECULE_PLAYBOOK:-playbook.yml} -scenario: - name: default +playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} verifier: - name: testinfra - lint: - name: flake8 + name: ansible diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml deleted file mode 100644 index 9fc76cc..0000000 --- a/molecule/default/playbook.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: Converge - hosts: all - become: true - - vars: - nodejs_install_npm_user: root - verdaccio_systemd_state: stopped - - pre_tasks: - - name: Update apt cache. - apt: update_cache=yes cache_valid_time=600 - when: ansible_os_family == 'Debian' - - roles: - - role: verdaccio.verdaccio diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..79044cd --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + assert: + that: true From c205ccddadb15e444337f109596fae277cd52153 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 20 Dec 2020 16:23:16 +0100 Subject: [PATCH 4/7] [#28] Molecule issues. --- molecule/default/molecule.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 4a9a940..7490710 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -6,10 +6,12 @@ driver: platforms: - name: instance image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: true pre_build_image: true provisioner: name: ansible -playbooks: - converge: ${MOLECULE_PLAYBOOK:-converge.yml} -verifier: - name: ansible + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} From cb2ee733e935d9cb4fc9e28445f1747200fd5cae Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 20 Dec 2020 18:00:25 +0100 Subject: [PATCH 5/7] [#28] Molecule issues. --- molecule/default/molecule.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 7490710..b5710a8 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -5,13 +5,9 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" - command: ${MOLECULE_DOCKER_COMMAND:-""} - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: true + image: docker.io/pycontribs/centos:8 pre_build_image: true provisioner: name: ansible - playbooks: - converge: ${MOLECULE_PLAYBOOK:-converge.yml} +verifier: + name: ansible From e63a299648f1e0f2e998fe64d18d3cd1fe1b0a2f Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 20 Dec 2020 21:03:37 +0100 Subject: [PATCH 6/7] [#28] Some dependencies required by newer molecule. --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5838fa9..e054a15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ --- language: python +python: + - 3.8 + services: docker env: @@ -19,8 +22,7 @@ before_install: - curl https://gist.githubusercontent.com/geerlingguy/ce883ad4aec6a5f1187ef93bd338511e/raw/36612d28981d92863f839c5aefe5b7dd7193d6c6/travis-ci-docker-upgrade.sh | sudo bash # yamllint disable-line install: - # Install test dependencies. - - pip install molecule docker + - curl https://gist.githubusercontent.com/030/fa2454b56c525286b39d549583173d8e/raw/c9f9cf439339819958e13cad1d5b5f719217d427/ansible-ci-requirements.sh | sudo bash # yamllint disable-line rule:line-length before_script: # Use actual Ansible Galaxy role name for the project directory. @@ -29,7 +31,6 @@ before_script: - cd $ORG_NAME.$ROLE_NAME script: - # Run tests. - molecule test notifications: From ef72d9d91d6b750a50944322e15615966ecedbe4 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 20 Dec 2020 22:26:48 +0100 Subject: [PATCH 7/7] [#28] Broken molecule. --- .travis.yml | 6 ------ molecule/default/converge.yml | 5 ++++- molecule/default/molecule.yml | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index e054a15..bfc3b38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,12 +24,6 @@ before_install: install: - curl https://gist.githubusercontent.com/030/fa2454b56c525286b39d549583173d8e/raw/c9f9cf439339819958e13cad1d5b5f719217d427/ansible-ci-requirements.sh | sudo bash # yamllint disable-line rule:line-length -before_script: - # Use actual Ansible Galaxy role name for the project directory. - - cd ../ - - mv ansible-$ROLE_NAME $ORG_NAME.$ROLE_NAME - - cd $ORG_NAME.$ROLE_NAME - script: - molecule test diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 4e0ea2f..87daaf0 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -3,5 +3,8 @@ hosts: all become: true + vars: + nodejs_install_npm_user: root + roles: - - role: verdaccio.verdaccio + - role: ansible-verdaccio diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index b5710a8..b92f159 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -5,9 +5,21 @@ driver: name: docker platforms: - name: instance - image: docker.io/pycontribs/centos:8 + image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: true pre_build_image: true provisioner: name: ansible + lint: + name: ansible-lint + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} +scenario: + name: default verifier: - name: ansible + name: testinfra + lint: + name: flake8