Chassis / Composer

An extensions to install Composer on your Chassis box
0 stars 3 forks source link

Unknown resource type: 'install' #37

Closed ntwb closed 4 years ago

ntwb commented 4 years ago

Apologies for not having the relevant details for below I'll endeavor to get this information tomorrow and update here

  1. What operating system do you use?

??? (Possibly Windows, maybe Mac)

  1. What version of Vagrant are you running?

??? (I believe the latest, a fresh install)

  1. Are you using VirtualBox or VMWare and which version are you using?

??? (I'm guessing Virtual Box)

  1. Do you have a custom YAML file? If so, what does it contain? (Please paste in your chassis.local.yaml file)

A HM Project I work on

  1. Do you have any Chassis other extensions installed? If so, what are they?

The issue appears to be isolated to the Composer Chassis extension


Error: [vagrant] default: Error: Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'install' (file: /vagrant/extensions/composer/modules/composer/manifests/init.pp, line: 63, column: 4) on node lol.local

This was introduced in the https://github.com/Chassis/Composer/commit/88c47f79d956a786906604c91b91c24d8833e04f commit

[vagrant]     default: Get:45 http://archive.ubuntu.com/ubuntu bionic-backports/main i386 Packages [2,516 B]
[vagrant]     default: Get:46 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2,512 B]
[vagrant]     default: Get:47 http://archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [1,644 B]
[vagrant]     default: Get:48 http://archive.ubuntu.com/ubuntu bionic-backports/universe i386 Packages [4,024 B]
[vagrant]     default: Get:49 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4,028 B]
[vagrant]     default: Get:50 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1,856 B]
[vagrant]     default: Fetched 32.5 MB in 16s (2,030 kB/s)
[vagrant]     default: Reading package lists...
[vagrant]     default: Reading package lists...
[vagrant]     default: Building dependency tree...
[vagrant]     default: Reading state information...
[vagrant]     default: puppet is already the newest version (5.4.0-2ubuntu3).
[vagrant]     default: 0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
[vagrant] ==> default: Running provisioner: shell...
[vagrant]     default: Running: inline script
[vagrant]     default: Error: Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'install' (file: /vagrant/extensions/composer/modules/composer/manifests/init.pp, line: 63, column: 4) on node lol.local
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Open http://lol.local/wp-admin/ in your browser? [y/N]
BronsonQuick commented 4 years ago

Alright, so looking at the output of that one it's been installed from a shell script. I've tried replicating it with a new version of Chassis and the composer extension and I'm unable to replicate it.

My guess would be that the Chassis box you're using might be outdated? For some version the Vagrant CLI doesn't have a command to display the box version that a project is using but you should be able to look in ~/.vagrant.d/data/machine-index/index to find that information.

Let me know how you go as I'm more than happy to keep digging or try something else to replicate it!

ntwb commented 4 years ago

Thanks @BronsonQuick, the team has now got it working, not sure how it was resolved but we can close this now

nprasath002 commented 4 years ago

The team manually install composer inside the machine and removed composer chasis extension from config to get this working.

ntwb commented 4 years ago

Note: That Composer was installed inside Vagrant using brew inside the box

ntwb commented 4 years ago

p.s I'll get those additional details from the user shortly

ntwb commented 4 years ago

User: OS : macOS Catalina version 10.15.2 Vagrant Version : 2.2.0 VirtualBox 5.2.32r132073

Me: No custom YAML file I believe, standard HM repo install for that project I work on Extensions: extensions:

BronsonQuick commented 4 years ago

@ntwb Thanks for that.

Any chance you can let me know which Chassis box version you're using?

My guess would be that the Chassis box you're using might be outdated? For some version the Vagrant CLI doesn't have a command to display the box version that a project is using but you should be able to look in ~/.vagrant.d/data/machine-index/index to find that information.

ntwb commented 4 years ago

I'll check, as it was (I believe) a fresh install I would have thought the box was the latest release as that would have been pulled down, will go ask and confirm

BronsonQuick commented 4 years ago

Awesome. Thank you Sir. I'm doing a fresh up with those extensions now. So I'll report back when it's provisioned.

BronsonQuick commented 4 years ago

The provision was successful. I'm wondering if the composer extension might be out of date? It might be worth changing into the extensions/composer directory and run git pull && vagrant provision.

ntwb commented 4 years ago

Pulling it all down myself now in a test folder, nothing has changed in recent times for that project I have been working on forever, so I'll test it myself and see what results I get

Will try that also

ntwb commented 4 years ago

I get the same error on my test local, scroll to the end of this comment, then read back up ;)


Anyways, on my test:

❯ cd chassis/extensions/composer/
~/Code/tmp/test/chassis/extensions/composer master
❯ git remote -v
origin  https://github.com/chassis/composer (fetch)
origin  https://github.com/chassis/composer (push)
~/Code/tmp/test/chassis/extensions/composer master
❯ git pull
Already up to date.
~/Code/tmp/test/chassis/extensions/composer master

Ran bash install.sh and working as expected:

Unpacking objects: 100% (91/91), done.
[vagrant] Bringing machine 'default' up with 'virtualbox' provider...
[vagrant] ==> default: Running action triggers before up ...
[vagrant] ==> default: Running trigger...
[vagrant] ==> default: 
[vagrant] ==> default: Box 'chassis/chassis' could not be found. Attempting to find and install...
[vagrant]     default: Box Provider: virtualbox
[vagrant]     default: Box Version: >= 3.0, < 4.0
[vagrant] ==> default: Loading metadata for box 'chassis/chassis'
[vagrant]     default: URL: https://vagrantcloud.com/chassis/chassis
[vagrant] ==> default: Adding box 'chassis/chassis' (v3.0.1) for provider: virtualbox
[vagrant]     default: Downloading: https://vagrantcloud.com/chassis/boxes/chassis/versions/3.0.1/providers/virtualbox.box
    default: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
==> default: Successfully added box 'chassis/chassis' (v3.0.1) for 'virtualbox'!
[vagrant] ==> default: Importing base box 'chassis/chassis'...
==> default: Matching MAC address for NAT networking...
[vagrant] ==> default: Checking if box 'chassis/chassis' version '3.0.1' is up to date...
[vagrant] ==> default: Setting the name of the VM: chassis_default_1578900033572_25498
[vagrant] ==> default: Clearing any previously set network interfaces...
[vagrant] ==> default: Preparing network interfaces based on configuration...
[vagrant]     default: Adapter 1: nat
[vagrant]     default: Adapter 2: hostonly
[vagrant] ==> default: Forwarding ports...
[vagrant]     default: 80 (guest) => 8000 (host) (adapter 1)
[vagrant]     default: 22 (guest) => 2222 (host) (adapter 1)
[vagrant] ==> default: Running 'pre-boot' VM customizations...
[vagrant] ==> default: Booting VM...
[vagrant] ==> default: Waiting for machine to boot. This may take a few minutes...
[vagrant]     default: SSH address: 127.0.0.1:2222
[vagrant]     default: SSH username: vagrant
[vagrant]     default: SSH auth method: private key
[vagrant] ==> default: Machine booted and ready!
[vagrant] ==> default: Checking for guest additions in VM...
[vagrant]     default: The guest additions on this VM do not match the installed version of
[vagrant]     default: VirtualBox! In most cases this is fine, but in rare cases it can
[vagrant]     default: prevent things such as shared folders from working properly. If you see
[vagrant]     default: shared folder errors, please make sure the guest additions within the
[vagrant]     default: virtual machine match the version of VirtualBox you have installed on
[vagrant]     default: your host and reload your VM.
[vagrant]     default: 
[vagrant]     default: Guest Additions Version: 6.1.0
[vagrant]     default: VirtualBox Version: 6.0
[vagrant] ==> default: Setting hostname...
[vagrant] ==> default: Configuring and enabling network interfaces...
[vagrant] ==> default: Mounting shared folders...
[vagrant]     default: /chassis => /Users/netweb/Code/tmp/test
[vagrant]     default: /vagrant => /Users/netweb/Code/tmp/test/chassis
[vagrant] ==> default: Detected mount owner ID within mount options. (uid: 1000 guestpath: /vagrant)
[vagrant] ==> default: Detected mount group ID within mount options. (gid: 33 guestpath: /vagrant)
[vagrant]     default: /var/log/php => /Users/netweb/Code/tmp/test/chassis/logs/php
[vagrant] ==> default: Detected mount owner ID within mount options. (uid: 1000 guestpath: /var/log/php)
[vagrant] ==> default: Detected mount group ID within mount options. (gid: 33 guestpath: /var/log/php)
[vagrant]     default: /var/log/nginx => /Users/netweb/Code/tmp/test/chassis/logs/nginx
[vagrant] ==> default: Detected mount owner ID within mount options. (uid: 1000 guestpath: /var/log/nginx)
[vagrant] ==> default: Detected mount group ID within mount options. (gid: 33 guestpath: /var/log/nginx)
[vagrant]     default: /vagrant/extensions/_global => /Users/netweb/.chassis/extensions
[vagrant] ==> default: Detected mount owner ID within mount options. (uid: 1000 guestpath: /vagrant/extensions/_global)
[vagrant] ==> default: Detected mount group ID within mount options. (gid: 33 guestpath: /vagrant/extensions/_global)
[vagrant] ==> default: Running provisioner: shell...
[vagrant]     default: Running: /var/folders/33/6sh192cx64v_v4st4f6vpjsh0000gn/T/vagrant-shell20200113-7347-1kii7ir.sh
[vagrant]     default: Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
[vagrant]     default: Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
[vagrant]     default: Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease [20.8 kB]
[vagrant]     default: Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main i386 Packages [52.1 kB]
[vagrant]     default: Get:5 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages [417 kB]
[vagrant]     default: Get:6 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
...
...
... Box updates continuing....

Right up until this:

[vagrant]     default: Get:49 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4,044 B]
[vagrant]     default: Get:50 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1,900 B]
[vagrant]     default: Fetched 32.5 MB in 14s (2,332 kB/s)
[vagrant]     default: Reading package lists...
[vagrant]     default: Reading package lists...
[vagrant]     default: Building dependency tree...
[vagrant]     default: Reading state information...
[vagrant]     default: puppet is already the newest version (5.4.0-2ubuntu3).
[vagrant]     default: 0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
[vagrant] ==> default: Running provisioner: shell...
[vagrant]     default: Running: inline script
[vagrant]     default: Error: Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'install' (file: /vagrant/extensions/composer/modules/composer/manifests/init.pp, line: 63, column: 4) on node sctest.local
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Open http://sctest.local/wp-admin/ in your browser? [y/N] 

So, same error:

[vagrant]     default: Error: Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'install' (file: /vagrant/extensions/composer/modules/composer/manifests/init.pp, line: 63, column: 4) on node sctest.local

Here's the contents of my ~/.vagrant.d/data/machine-index/index file


        "1f38abc92f664170aa0fb684d519298f": {
            "local_data_path": "/Users/netweb/Code/tmp/test/chassis/.vagrant",
            "name": "default",
            "provider": "virtualbox",
            "state": "running",
            "vagrantfile_name": null,
            "vagrantfile_path": "/Users/netweb/Code/tmp/test/chassis",
            "updated_at": null,
            "extra_data": {
                "box": {
                    "name": "chassis/chassis",
                    "provider": "virtualbox",
                    "version": "3.0.1"
                }
            }
        }
BronsonQuick commented 4 years ago

@ntwb I'll need to see what's in your install.sh script as that's the only thing that's different.

ntwb commented 4 years ago

Looking inside Vagrant, Composer has not been installed

vagrant@sctest:/chassis$ which curl
/usr/bin/curl
vagrant@sctest:/chassis$ php --version
PHP 7.3.13-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec 18 2019 14:48:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.13-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
vagrant@sctest:/chassis$ which curl
/usr/bin/curl
vagrant@sctest:/chassis$ puppet --version
5.4.0

So this https://github.com/Chassis/Composer/commit/88c47f79d956a786906604c91b91c24d8833e04f commit still appears to be the cause, for whatever reason of the environment inside the Vagrant box Composer is not being installed

🤔

BronsonQuick commented 4 years ago

Does this happen to be Chassis with a paths setup? If so, does changing https://github.com/Chassis/Composer/commit/88c47f79d956a786906604c91b91c24d8833e04f#diff-1d7b4e3b0e560baa0fae242b9b97f691R10 from /vagrant/${name} to have /chassis/${name} change anything?

nprasath002 commented 4 years ago

I am new to puppet and spent some time on this today. Here are my findings

1

If so, does changing 88c47f7#diff-1d7b4e3b0e560baa0fae242b9b97f691R10 from /vagrant/${name} to have /chassis/${name} change anything?

The type has changed to the following since that commit

    define install {
        exec { "Installing Composer ${name}":
            environment => [ 'COMPOSER_HOME=/usr/bin/composer' ],
            path        => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ],
            cwd         => $name,
            command     => "composer install ${config[composer][options]}",
            require     => [ Exec['install composer'] ],
            logoutput   => true,
            onlyif      => 'test ! -d vendor'
        }
    }

2

I've tried replicating it with a new version of Chassis and the composer extension and I'm unable to replicate it.

I tried with fresh chasis install with composer extension and i am unable to replicate as well. The problem is

I'll need to see what's in your install.sh script as that's the only thing that's different.

We have a defined config that is copied to a chassis/config.local.yaml. There we have defined couple of composer paths

composer:
    paths:
    - /chassis/content/plugins-mu/vendor/memcached-adapter
    - /chassis/content/plugins-mu/vendor/simple-cache-bridge
    - /chassis/content/plugins-mu/vendor/PhpSpreadsheet

3

Placing a defined type outside the class works fine.

define tmpfile() {
    file { "/tmp/${name}.php": content => "Hello, world\n",
    }
  }

I tried defining below outside the class and called it inside the class and it worked fine.

tmpfile { ['a', 'b', 'c']: }

4

        if ( $config[composer] and $config[composer][paths]) {
            install { $config[composer][paths]: }
        }

I changed the above to code to below and it worked fine

        if ( $config[composer] and $config[composer][paths]) {
            composer::install { $config[composer][paths]: }
        }

From the documentation

Define statements may also be placed inside class definitions; this gives the user defined type a name in the class’ namespace (a user defined type ‘mytype’ inside the class ‘myclass’ is given the name ‘myclass::mytype’.

The above seems to be the issue.

BronsonQuick commented 4 years ago

@nprasath002 Champion. The paths was the bit of information that I was missing which is why I couldn't replicate it. I'll fix that one up for you tonight

ntwb commented 4 years ago

Thank you kind sir 🙇

nprasath002 commented 4 years ago

Thanks a lot @BronsonQuick