Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Friday, July 21, 2017

Getting started with Ansible

If you try to get started with Ansible you will probably be disappointed!
You will see tutorial explaining that you need a host file located at /etc/ansible/hosts, that you need to connect with ssh.

But what do you really want to start with?
Experiment locally, on your local machine. And that is not described in these tutorials :(

Luckily, I found a blog @mechanicalfish which explains exactly how to start.

The Shortest Path To Using Ansible
A One-Line Configuration

$ ansible all -i 'localhost,' -c local -m ping

Let’s take our one-liner apart. Could we make it shorter or simpler?
  • ansible is the command which runs one task at a time all tells Ansible to run this task on all the hosts in the inventory.
  • -i localhost, …is a trick, to avoid the need to make an inventory file. -i means “here is the pathname of the inventory file”. But ansible has a poorly-documented bonus feature: Instead of a path, we can choose to provide a list of host names, each of which names a computer on the network. And our list can have just one entry, localhost. (The weird extra comma after localhost is vital; do not leave it out. It tells Ansible that this is a list of hosts and not a pathname.)
  • -c local is shorthand for --connection=local. It tells Ansible not to try to use SSH to contact the hosts, but to run tasks on our local computer instead. Ansible uses SSH by default, because usually it’s running tasks on faraway machines in the cloud. However, it’s common to encounter problems when connecting to your own computer via SSH, and fixing these problems without impairing your security is tricky and not worth the effort.
  • Finally, -m means “use this Ansible module”, and ping is the name of the module. The ping module contacts the host and proves that it’s listening.

I would recommend the reading of the post, as there are more details in it :).
Thank you Mechanical Fish for this post.



Once this is read I would check the following tutorial by black sail division
Part 1
Part 2
Part 3


Thursday, March 16, 2017

IntelliJ on Ubuntu the false promises

I guess every one who develops with IntelliJ on Ubuntu is disappointed that the keyboard shortcuts do not work as they should.
The problem is that Ubuntu (Linux in general) maps a lot of keyboard shortcuts.

Here is the list of keyboard shortcut doing problems but that I do need in IntelliJ:
  • Ctrl+Alt+Left/Right : back in IntelliJ
  • Ctrl+Alt+L : reformat code
  • Alt+F7 : find usage
  • Alt+F8 : evaluate expression
  • Ctrl+Alt+S : settings dialog
  • Alt+Mouse Button 1 : Block selection
  • Ctrl+Shift+U : to uppercase
  • Alt+F1 : select in

First if you are working in a virtual machine like VmWare

Ctrl+Alt+Left is most probably used to switch between vm. So is you are using VmWare navigate to and change the combination
  • VmWare: Edit->preferences->hot keys

Some of these can be changed in Ubuntu keyboard settings

For these I used to remove the settings in Ubuntu.
  • Ctrl+Alt+L : settings->keyboard->shortcuts->system->lock screen
  • Alt+F7 : settings->keyboard->shortcuts->windows->move window
  • Alt+F8 : settings->keyboard->Windows->resize window 
  • Ctrl+Alt+S : settings->keyboad->windows-> toggle shade state

Some can be set at other places in the gui.

In the dconf editor: 
  • Alt+Mouse Button 1 /org/gnome/desktop/wm/preferences/mouse-button-modifier
    You can't just disable the key, you must assign it to something fancy like Ctrl+Alt+Shift+Super+Escape
This one is still at another location

The interesting part is that some of these can be changed on the console:

Changing keyboard shortcut from the command line

In order to have the complete list of shortcut available, try this command
gsettings list-recursively

Which gives us the following commands
  • Ctrl+F8 : gsettings set org.gnome.desktop.wm.keybindings begin-resize "['disabled']"
  • Ctrl+Alt+S : gsettings set org.gnome.desktop.wm.keybindings toggle-shaded "['disabled']"
  • Ctrl+Alt+L: dconf write /org/gnome/desktop/screensaver/lock-enabled false
  • Alt+Mouse Button 1: gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "['Escape']"
  • Ctrl+Alt+Right : gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "['disabled']"
  • Ctrl+Alt+Left : gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "['disabled']"

Ansible

We can take this a step further and use ansible.
By putting this script in a file: e..g, main.yml in ubuntu/tasks folder, with a hosts file containing 

hosts file
[localhost]

localhost ansible_user=dev ansible_connection=local

playbook.yml file
- hosts: localhost
  roles:
  - intellij

  - ubuntu

note that the initellij task do some additional configuration. like a quick list config etc.

Finally the following command should do the trick:

ansible-playbook -i hosts playbook.yml

- name: disable screen lock see http://xmodulo.com/control-screen-lock-settings-linux-desktop.html
  command: dconf write /org/gnome/desktop/screensaver/lock-enabled false
  tags: [ubuntu]

- name: disable mouse-button-modifier do not disable dconf Editor key /org/gnome/desktop/wm/preferences/mouse-button-modifier
  command: gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "['Escape']"
  tags: [ubuntu]

- name: disable keyboard->Navigation->switch workspace org.gnome.desktop.wm.keybindings switch-to-workspace-right ['Right']
  command: gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "['disabled']"
  tags: [ubuntu]

- name: disable keyboard->Navigation->switch workspace org.gnome.desktop.wm.keybindings switch-to-workspace-left ['left']
  command: gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "['disabled']"
  tags: [ubuntu]

- name: disable keyboard->Windows->resize window | evaluate expression org.gnome.desktop.wm.keybindings begin-resize ['F8']
  command: gsettings set org.gnome.desktop.wm.keybindings begin-resize "['disabled']"
  tags: [ubuntu]

- name: disable S shortcut. keyboad->windows-> toggle shade state
  command: gsettings set org.gnome.desktop.wm.keybindings toggle-shaded "['disabled']"

  tags: [ubuntu]

Short cut to change in IntelliJ

 - The Navigate -> Select in shortcut is normally mapped to Alt-F1 which I do not want to unmap in Ubuntu. So I add another shortcut in IntelliJ

File->Settings->Keymap->Main menu->Navigate->Select In 
And I give the short cut: Ctrl-§

References

Alt+Left Button  see http://askubuntu.com/questions/118151/how-do-i-disable-window-move-with-alt-left-mouse-button-in-gnome-shell
I don't know how to deactivate Alt+F1 so I have to change the mapping in IntelliJ
check this post : http://askubuntu.com/questions/412046/unable-to-use-intellij-idea-keyboard-shortcuts-on-ubuntu



Wednesday, December 1, 2010

Choose default java version in Ubuntu

I got annoyed today, as I needed the sun jdk on my Ubuntu machine.
I had to goodle a while before finding how to change the default from open jdk to sun jdk

The how to is located here.

But I reproduce the text here:

Choosing the default Java to use

  • Open a Terminal window
  • Run sudo update-java-alternatives -l to see the current configuration and possibilities.
  • Run sudo update-java-alternatives -s XXXX to set the XXX java version as default. For Sun Java 6 this would be sudo update-java-alternatives -s java-6-sun
  • Run java -version to ensure that the correct version is being called.
You can also use the following command to interactively make the change;
  • Open a Terminal window
  • Run sudo update-alternatives --config java
  • Follow the onscreen prompt
I still would prefer some gui to perform this. But it is a start.

Thursday, May 13, 2010

Taxme Ubuntu Lucid Lynx

Well this post is very strongly Swiss oriented and of no interest to anyone not living in Bern.

I downloaded the new Taxme software, for paying taxes, nothing very funny!
Unfortunately, it worked fine with Ubuntu 9.10, but with Lucid, it just did not start.
Silently without any notice. The log was not very explicit, but I then tried to start the application with root. And it worked.

i.e. from the console:

sudo ./TaxMeBe2009

There is still a problem with the help which cannot be displayed as apparently the application cannot find firefox.

Strangely I had to download the version with the java virtual machine. But this is most probably due to the fact that I have a 64b system

Monday, May 10, 2010

Ubuntu lucid lynx post installation

There is a few things you need to do after installing Unubu lucid lynx

1. Ubuntu restricted extra (thank you Ranjith Siji, even if I saw it also elsewhere). The problem is if you want real Java as I do, you will have to remove openJDK 6 and install the sun version.

2. As I use gmail on the web, I found a well integrated application (thank D0od ). It is perfectly integrated into the me menu. The problem is you can only watch one mail account at the time.

To install it open a terminal and enter the following lines carefully: -

  • sudo add-apt-repository ppa:gm-notify-maintainers/ppa
  • sudo apt-get update && sudo apt-get install gm-notify

To set up your GMail account with GMail Notifier head to System > Preferences > GMail Notifier Configuration. From here you can also specify alert sounds, labels and on-launch preferences.

3. Skype I'm not very happy that Skype is not in the repositories anymore, thus you have to download it from the skype site

4. vlc media player

5. Desktop Webmail allows an additional integration between gmail and Ubuntu. (Thank you Kaba)
After installing Desktop Webmail (sudo apt-get install desktop-webmail) set-it-up as your default e-mail client in System -> Preferences -> Preferred Application – > Mail Reader, replacing Evolution with desktop-webmail.

Wednesday, June 24, 2009

Environment Variables in Ubuntu

I got some problems to find out where I should define environment variable in Ubuntu.
I had to search a while and finally found the right page:

https://help.ubuntu.com/community/EnvironmentVariables

in summary
  • ~/.profile - This is probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.

  • ~/.bash_profile or ~./bash_login - If one of these file exist, bash executes it rather then "~/.profile" when it is started as a login shell. (Bash will prefer "~/.bash_profile" to "~/.bash_login"). However, these files won't influence a graphical session by default.

  • ~/.bashrc - Because of the way Ubuntu currently sets up the various script files by default, this may be the easiest place to set variables in. The default configuration nearly guarantees that this file will be executed in each and every invocation of bash as well as while logging in to the graphical environment. However, performance-wise this may not be the best thing to do since it will cause values to be unnecessarily set many times.