Hello. I have worked on the front end of a few Sage sites, but am currently muddling through my first try at setting up a full Trellis/Bedrock/Sage stack.
I’ve been following the Trellis docs, and just reached the end of Remote Server Setup. My attempt to deploy to a staging subdomain on a Digital Ocean droplet failed here:
TASK: [ssmtp | Install ssmtp] *************************************************
failed: [159.203.19.27] => {"failed": true}
stderr: hostname: Name or service not known
dpkg: error processing package ssmtp (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
ssmtp
E: Sub-process /usr/bin/dpkg returned an error code (1)
stdout: Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
ssmtp
0 upgraded, 1 newly installed, 0 to remove and 31 not upgraded.
Need to get 46.2 kB of archives.
After this operation, 8192 B of additional disk space will be used.
Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty/universe ssmtp amd64 2.64-7 [46.2 kB]
Preconfiguring packages ...
Fetched 46.2 kB in 0s (669 kB/s)
Selecting previously unselected package ssmtp.
(Reading database ... 93164 files and directories currently installed.)
Preparing to unpack .../ssmtp_2.64-7_amd64.deb ...
Unpacking ssmtp (2.64-7) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up ssmtp (2.64-7) ...
msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" install 'ssmtp'' failed: hostname: Name or service not known
dpkg: error processing package ssmtp (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
ssmtp
E: Sub-process /usr/bin/dpkg returned an error code (1)
I also received this recap:
PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/matthewmckinnon/server.retry
159.203.19.27 : ok=48 changed=30 unreachable=0 failed=1
localhost : ok=0 changed=0 unreachable=0 failed=0
Unsure where to go from here—or whether these snippets are enough to say what the problem is. Any guidance would be wonderful.
I’m looking at it now, thanks, although unsure how to proceed. Running hostname --fqdn on my droplet indeed returns hostname: Name or service not known, so does that make the snippet below (taken from that link) my next logical step? If so, I’d love to know where to put it.
Meanwhile, entirely possible I mucked up hosts/production and/or hosts/staging—it’s the step of Remote Server Setup I found hardest to follow. My effort at the latter…
# Add each host to the [staging] group and to a "type" group such as [web] or [db].
# List each machine only once per [group], even if it will host multiple sites.
[staging]
159.203.19.27
[web]
159.203.19.27
I also am unsure where to apply the above fix for an unknown hostname. Any guidance here would be appreciated. My hostnames in my hosts/staging are set to the hostname I used when I created my instance (staging.curvyyoga.studio) but I’m still failing on the ssmtp step with the same error as above.
@curvyyoga As you discovered, on DreamCompute Ubuntu 16.04 the command hostname --fqdn apparently returns hostname: Name or service not known and the Install ssmtp task fails.
- name: Retrieve hostname FQDN
command: hostname --fqdn
register: hostname_fqdn
failed_when: false
changed_when: false
- name: Set hostname FQDN if missing
hostname:
name: "{{ wordpress_sites.values() | map(attribute='site_hosts') | first | map(attribute='canonical') | first }}"
when: hostname_fqdn.stdout == ""
It worked for me on DreamCompute Ubuntu 16.04. If it doesn’t work at first, you may have to “Rebuild Instance” and clear the corresponding host’s entry from your known_hosts.
I don’t know all the implications but it could be useful to have some version of this in Trellis core. Just a few related dev notes:
… yields staging as the hostname for a DreamCompute Instance named staging.example.com. My proposed tasks attempt to get an actual FQDN, but note that the first filter is not guaranteed to get the first canonical item from the wordpress_sites list because Ansible/Python doesn’t maintain original sort order of dicts such as wordpress_sites. So, the FQDN could end up example2.com even if example1.com is listed first.