GithubHelp home page GithubHelp logo

danschultzer / ansible-phoenix-build Goto Github PK

View Code? Open in Web Editor NEW
60.0 4.0 8.0 736 KB

Sample app with full build and deploy setup of a Phoenix app using ansible

Home Page: https://dreamconception.com/tech/phoenix-automated-build-and-deploy-made-simple/

License: MIT License

JavaScript 7.70% CSS 21.89% Shell 2.40% Elixir 57.70% HTML 4.47% DIGITAL Command Language 2.52% Dockerfile 3.31%
ansible phoenix elixir production deploy build distillery

ansible-phoenix-build's People

Contributors

danschultzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ansible-phoenix-build's Issues

bin/deploy -- UNREACHABLE

I have port 22 opened on maz.me, and have my public key found locally in ~/.ssh/id_rsa.pub also in the /home/maz/.ssh/authorized_keys file on maz.me. I have confirmed that I can connect on port 22

I edited the bin/deploy where I append -u maz to the ansible-playbook call:

ansible-playbook -i apps/production/inventory apps/production/deploy.yml -vvv -u maz

I also tried setting {{ ansible_user }} to maz
and adding ansible_user: maz to the maz.me, inventory files

After all these changes I still get the error below when I run bin/deploy .. do you what I am missing?

fatal: [maz.me]: UNREACHABLE! => {
    "changed": false,
    "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp/ansible-tmp-1514429373.232328-174544729471745 `\" && echo ansible-tmp-1514429373.232328-174544729471745=\"` echo ~/.ansible/tmp/ansible-tmp-1514429373.232328-174544729471745 `\" ), exited with result 1",
    "unreachable": true
}

No module named ssl_match_hostname

When I make a python27 virtualenv, try source path/to/py27/bin/activate, pip install ansible, pip install docker, pip install docker-py and then:

ansible-playbook apps/build/update-docker-image.yml -vvv

I get the error:

"msg": "Failed to import docker-py - No module named ssl_match_hostname. Try `pip install docker-py`"

different behavior, same commands, almost: bin/deploy vs. ansible-playbook -i apps/production/inventory apps/production/deploy.yml -vvv

on the remote machine, I do:
create a remote deploy user(a sudoer)
add my deployment machine public rsa key to /home/deploy/.ssh
sudo chmod 700 -R ~/.ssh && chmod 600 ~/.ssh/authorized_keys
then in /etc/sudoers:
deploy ALL=NOPASSWD: /bin/systemctl restart ansible_phoenix_build
adding a new service to /etc/systemd/system/ansible_phoenix_build.service as in the README.md file

while in the .ansible dir I try: ansible-playbook -i apps/production/inventory apps/production/deploy.yml -vvv

I get the error where rsync fails:

fatal: [maz.me]: FAILED! => {
    "changed": false,
    "cmd": "/usr/bin/rsync --delay-updates -F --compress --delete-after --archive --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --rsync-path=sudo -u deploy rsync --out-format=<<CHANGED>>%i %n%L /tmp/ansible_phoenix_build/_build/prod/rel/ansible_phoenix_build/ [email protected]:/u/apps/ansible_phoenix_build/releases/2018.01.021957",
    "invocation": {
        "module_args": {
            "_local_rsync_path": "rsync",
            "_substitute_controller": false,
            "archive": true,
            "checksum": false,
            "compress": true,
            "copy_links": false,
            "delete": true,
            "dest": "[email protected]:/u/apps/ansible_phoenix_build/releases/2018.01.021957",
            "dest_port": null,
            "dirs": false,
            "existing_only": false,
            "group": null,
            "links": null,
            "mode": "push",
            "owner": null,
            "partial": false,
            "perms": null,
            "private_key": null,
            "recursive": true,
            "rsync_opts": null,
            "rsync_path": "sudo -u deploy rsync",
            "rsync_timeout": 0,
            "set_remote_user": true,
            "src": "/tmp/ansible_phoenix_build/_build/prod/rel/ansible_phoenix_build/",
            "ssh_args": null,
            "times": null,
            "verify_host": false
        }
    },
    "msg": "Warning: Permanently added 'maz.me,96.126.108.34' (ECDSA) to the list of known hosts.\r\nrsync: connection unexpectedly closed (8 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52/rsync/io.c(453) [sender=2.6.9]\n",
    "rc": 12
}

while in the ansible-phoenix-build dir I do: bin/deploy
I get the error:

fatal: [maz.me]: UNREACHABLE! => {
    "changed": false,
    "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp/ansible-tmp-1514941963.299496-109181809637189 `\" && echo ansible-tmp-1514941963.299496-109181809637189=\"` echo ~/.ansible/tmp/ansible-tmp-1514941963.299496-109181809637189 `\" ), exited with result 1",
    "unreachable": true
}

What do the two errors mean? I believe with the former command I am much closer to deploying successfully. With the former is the issue that I am running the command with --root?

Postgrex -- tcp connect (localhost:5432): connection refused

Deploying the docker app locally seems to have port 5432 closed because after doing

../../py27env/bin/ansible-playbook -i apps/build/inventory apps/build/build.yml -vvv
docker attach ansible_phoenix_build_build_server
cd build/_build/prod/rel/ansible_phoenix_build
bin/ansible_phoenix_build foreground

Then repeatedly:

03:15:55.984 [error] Postgrex.Protocol (#PID<0.1316.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

Any suggestions?

Blog Suggestion

This may be helpful for others when generating passwords with the vaultfile. On your blog at https://dreamconception.com/tech/phoenix-automated-build-and-deploy-made-simple/ you have:

Create .ansible/apps/production/host_vars/MY_HOST (remember to change the MY_HOST filename to the domain of your production website), and add the encrypted secrets one by one by running ansible-vault encrypt_string --vault-password-file=.ansible/.vault_pass.txt. You should hit ctrl-d twice (not enter) to encrypt the secret. Paste them into your MY_HOST file so it looks similar to this:

I would point out that for ansible 2.4 and higher you can now use --stdin-name to manually enter a passphrase. So for example we can make two keys to be pasted into the MY_HOST file like this:

ansible-vault encrypt_string --vault-id .ansible/.vault_pass.txt --stdin-name 'secret_key_base'
<enter the passphrase><CTRL-D><CTRL-D>
<copy to clipboard and paste into MY_HOST>
ansible-vault encrypt_string --vault-id .ansible/.vault_pass.txt --stdin-name 'database_password'
<enter the passphrase><CTRL-D><CTRL-D>
<copy to clipboard and paste into MY_HOST>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.