Anmsible and Docker are tool to deploy software in Azure, e.g. PostgreSQL deployment in Azure.

Ansible

sudo apt-get update
sudo apt-get install ansible
sudo apt-get install git
  • Check whether Ansible installed, e.g. with check version: 2.0.0.2
 ansible --version
  • Test

ansible all -i "localhost," -c local -m shell -a 'echo hello world'
  • Make essential files to test Ansible
    • inventory (name can be different, but this is convention)

      [local] 
      localhost ansible_connection=local
    • playbook.yml (name can be different, but this is convention)

      ---
      - name: Hello Ansible - quick start
        hosts: all
      
        tasks:
          - name: add current date to now.txt file
            shell: date >> now.txt 

Run ansible-playbook

ansible-playbook playbook.yml --inventory inventory --user `whoami`
# or in short format:
ansible-playbook playbook.yml -i inventory -u `whoami`

Docker

Install docker to be able to run docker images. See also: https://github.com/openearth-stack/general/blob/master/testing.md

sudo apt-get install docker.io
# add user, see git
# docker run -it quay.io/travisci/travis-ruby /bin/bas

Become a member of the docker group

sudo usermod -aG docker $(whoami)
# or alternatives to manually add your username to
# docker:x:117:USERNAME
# >> vigr
# >> sudo nano /etc/group

Exit and log back to to make these changes effective. Create a shadow group

vigr -s

Run docker to install for instance a postgres container (https://hub.docker.com/_/postgres/)

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

You can see the container in

sudo ls /var/lib/docker/containers

YOu can run a second docker that talks to the first (using mysecretpassword)

docker run -it --rm --link some-postgres:postgres postgres psql -h postgres -U postgres
  • No labels