To install both packages this should be:

```yaml
- name: Install Java
  apt: pkg={{ item }} state=present
  sudo: true
  with_items:
  - openjdk-7-jdk
  - openjdk-7-jre
```