Thursday, October 27, 2016

Git : create new branch

https://github.com/Kunena/Kunena-Forum/wiki

https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches

Create the branch on your local machine and switch in this branch : 
$ git checkout -b [name_of_your_new_branch]
Push the branch on github : 
$ git push origin [name_of_your_new_branch]

Wednesday, October 26, 2016

MacOS : Homebrew

Issue:
/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory
Error: update-report should not be called directly!

Solution:

$ cd "$(brew --repository)" && git fetch && git reset --hard origin/master
HEAD is now at 4284b82 Merge pull request #1380 from woodruffw/silence-git


Friday, October 21, 2016

Ansible : template with different set of variables

http://stackoverflow.com/questions/31142369/how-to-use-template-module-with-different-set-of-variables

Ansible : Switch a user per task

http://stackoverflow.com/questions/21344777/how-to-switch-a-user-per-task-or-set-of-tasks

http://stackoverflow.com/questions/37200337/is-there-anyway-to-run-multiple-ansible-playbooks-as-multiple-users-more-efficie/

Ansible uses the become, become_user, and become_method directives to achieve privilege escalation. You can apply them to an entire play or playbook, set them in an included playbook, or set them for a particular task.
- name: checkout repo
  git: repo=https://github.com/some/repo.git version=master dest={{ dst }}
  become: yes
  become_user: some_user
You can set the become options per:
  • playbook
  • role
  • task
Per playbook:
- hosts: whatever
  become: yes
  become_user: my_username
  roles:
    - checkout_sources
    - install_dependencies
    - make_dirs
Per role:
- hosts: whatever
  roles:
    - checkout_sources
    - role: install_dependencies
      become: yes
      become_user: my_username
    - make_dirs
Per task:
- shell: do something
  become: yes
  become_user: my_username
You can combine this however you like. The playbook can run as user A, a role as user B and finally a task inside the role as user C.

Ansible : tuning SSH timeout

Issue: Sometime we need extra wait time for Ansible host to establish SSH connection with target client

msg: Timeout (12s) waiting for privilege escalation prompt

Solution:

Modify /etc/ansible/ansible.cfg

By Default SSH timeout is set to 10 sec and python module will add 2 more seconds

timeout = 10

Thursday, September 22, 2016

Ansible : parameterize roles by adding variables

http://docs.ansible.com/ansible/playbooks_roles.html

- hosts: webservers
  roles:
    - common
    - { role: foo_app_instance, dir: '/opt/a',  app_port: 5000 }
    - { role: foo_app_instance, dir: '/opt/b',  app_port: 5001 }

Wednesday, September 21, 2016

Ansible : reboot a server and wait for it to come back

https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back

- name: restart machine
  shell: sleep 2 && shutdown -r now "Ansible updates triggered"
  async: 1
  poll: 0
  ignore_errors: true

- name: waiting for server to come back
  local_action: wait_for host={{ inventory_hostname }} port=22 delay=30 timeout=300