Build React Native App (4) - Redux, Jest, and NativeBase

Image
From this blog, typescript feature will be added. There are couple of ways to implement static type checking like; flow from facebook, PropTypes and Typescript. Typescript is well integrated with Visual Studio Code and supports better linter, error messages, and intellisense. Reference site Github Sample Ex4 Currnet version D:\GitRepo\reactnative>npm --version 6.3.0 D:\GitRepo\reactnative>react-native --version react-native-cli: 2.0.1 react-native: n/a - not inside a React Native project directory D:\GitRepo\reactnative>yarn --version 1.9.4 Creating React Native App $ react-native init ex4 If you want to specify the version, add "--version 0.57.3" at the end. Add NativeBase to React Native $ npm install native-base --save ... + native-base@2.8.1 added 71 packages from 42 contributors, removed 50 packages, updated 829 packages and audited 34989 packages in 138.542s found 0 vulnerabilities $ $ yarn yarn install v1.9.4 warning package-lock.json found. You

Automation with Ansible (7) - Accessing inventory host variable from playbook

Accessing host variable from playbook overview

Before writing full script, I need to learn how to access variables from host file. I tried to use range varible from host variable, but this doesn't work.

Host file

filename is "dockerhosts"

[dockermasters]
dockermaster01 ipaddr=10.200.0.152
dockermaster02 ipaddr=10.200.0.153

[dockerworkers]
dockerworkders01 ipaddr=10.200.0.154
dockerworkders02 ipaddr=10.200.0.155
dockerworkders03 ipaddr=10.200.0.156

YAML playbook file

filename is "test.yaml"

---
- name: Access Inventory Variable
  hosts: dockermasters
  connection: local
  # vars:
  #   - ip: "{{ hostvars['hostname'][client_ip] }}"
  #   - hostname: "{{ hostvars['hostname'][client_hostname] }}"
  tasks:
    - name: createVM from Template
      debug:
        var: hostvars[inventory_hostname]['ipaddr']
    - name: show hostname
      debug:
        msg: "hostname is {{ inventory_hostname }}"

Result

[ansible@ansible01 test]$ ansible-playbook -i dockerhosts test.yaml

PLAY [Create VM from Docker Master] ********************************************

TASK [Gathering Facts] *********************************************************
ok: [dockermaster01]
ok: [dockermaster02]

TASK [createVM from Template] **************************************************
ok: [dockermaster01] => {
    "hostvars[inventory_hostname]['ipaddr']": "10.200.0.152"
}
ok: [dockermaster02] => {
    "hostvars[inventory_hostname]['ipaddr']": "10.200.0.153"
}

TASK [show hostname] ***********************************************************
ok: [dockermaster01] => {
    "msg": "hostname is dockermaster01"
}
ok: [dockermaster02] => {
    "msg": "hostname is dockermaster02"
}

PLAY RECAP *********************************************************************
dockermaster01             : ok=3    changed=0    unreachable=0    failed=0
dockermaster02             : ok=3    changed=0    unreachable=0    failed=0

[ansible@ansible01 test]$

Summary

Now we are ready to generate full VMs using host variable.

Comments

Post a Comment

Popular posts from this blog

Export folder structure to file on Windows, Mac, and Linux

Adding SOAP Header generated by JAXB(wsimport)

Sample application for Active Directory SSO with Spring Security 4 and Waffle